Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check/filter uppercase words alone from a string using C#?

How to check/filter uppercase words alone from a string using C#? I don't want to use "Char.IsUpper()" by looping through each letter of a word for checking Upper case for the same. Is there any way very simple code to accomplish this task? with LINQ etc.?

like image 448
venkat Avatar asked Dec 22 '22 16:12

venkat


1 Answers

What about this?

string test = "This IS a STRING";
var upperCaseWords = test.Split(' ').Where( w => w == w.ToUpper());

upperCaseWords now contain all upper case words in the string.

like image 154
Øyvind Bråthen Avatar answered Jan 20 '23 17:01

Øyvind Bråthen