Mega Code Archive

 
Categories / C# / Data Types
 

Get char type

using System; using System.Data; using System.Text.RegularExpressions; using System.Text; class Class1{         static void Main(string[] args){             Console.WriteLine(GetCharKind('f'));             Console.WriteLine(GetCharKind('0'));             Console.WriteLine(GetCharKind('.'));             Console.WriteLine(GetCharKind('}'));         }     public static String GetCharKind(char theChar)     {       if (Char.IsControl(theChar))       {         return "Control";       }       else if (Char.IsDigit(theChar))       {         return "Digit";       }       else if (Char.IsLetter(theChar))       {         return "Letter";       }       else if (Char.IsNumber(theChar))       {         return "Number";       }       else if (Char.IsPunctuation(theChar))       {         return "Punctuation";       }       else if (Char.IsSeparator(theChar))       {         return "Separator";       }       else if (Char.IsSurrogate(theChar))       {         return "Surrogate";       }       else if (Char.IsSymbol(theChar))       {         return "Symbol";       }       else if (Char.IsWhiteSpace(theChar))       {         return "Whitespace";       }       else       {         return "Unknown";       }     } }