Wednesday, September 17, 2014

C# code for seperating lowes case, upper case,symbol, numbers and printing it as o/p with as individual group !

 Source Code:
Eg. S%t4*s8f2g# then o/p must be
 Lower case : t s f g 
Upper case : S 
Numbers : 4 8 2 
Symbols : % * #
 like this

string full = "AaBcDarR%4~@12'#3";

string lower = new string(full.Where( c => char.IsLetter(c) && char.IsLower(c) ).ToArray());

string upper = new string(full.Where( c => char.IsLetter(c) && char.IsUpper(c) ).ToArray());

string numeric = new string(full.Where( c => char.IsNumber(c) ).ToArray());

string symbols = new string(full.Where( c => char.IsLetterOrDigit(c) == false ).ToArray());


Console.WriteLine(lower);

Console.WriteLine(upper);

Console.WriteLine(numeric);

Console.WriteLine(symbols);

No comments:

Post a Comment