The System.Char class has a large number of static methods that serve as utility methods for getting information about individual characters.
Here are some examples:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| char c1 = '2';double d1 = char.GetNumericValue(c1); // Convert '2' to 2.0UnicodeCategory cat = char.GetUnicodeCategory('a'); // LowercaseLettercat = char.GetUnicodeCategory('+'); // MathSymbolcat = char.GetUnicodeCategory('6'); // DecimalDigitNumber// Check for control charactersbool isCtrl = char.IsControl('a'); // falseisCtrl = char.IsControl('\t'); // true// Check for digitsbool isDigit = char.IsDigit('a'); // falseisDigit = char.IsDigit('3'); // true// Check for lettersbool isLetter = char.IsLetter('%'); // falseisLetter = char.IsLetter('P'); // trueisLetter = char.IsLetter('ǽ'); // truebool lord = char.IsLetterOrDigit('j'); // true// Check for lower/upper casebool low = char.IsLower('j'); // truelow = char.IsLower('Y'); // falsebool upper = char.IsUpper('Ǻ'); // true// Check for numbersbool isnum = char.IsNumber('4'); // trueisnum = char.IsNumber('௧'); // trueisnum = char.IsNumber('X'); // false// Otherbool ispunc = char.IsPunctuation('?'); // truebool issep = char.IsSeparator(' '); // truebool issymbol = char.IsSymbol('$'); // true// Unicodebool issur = char.IsSurrogate('\xd840'); // truebool islow = char.IsLowSurrogate('\xd840'); // falsebool ishigh = char.IsHighSurrogate('\xd840'); // true// Conversionchar upp = char.ToUpper('a'); // Achar lower = char.ToLower('a'); // alower = char.ToLower('Y'); // y |

