Data Type - char
System.Char
Char Class
This deals with individual characters
Represents a 16 bit unicode character
With Option Strict On you must convert a String type such as "A" into a Character type by using CChar()
Smallest value is \u000
Largest value is \uFFFF
The Char data type can hold a single Unicode character
The Char class represents a single character.
This class exposes a number of useful shared methods that let you test a single character according to several criteria
All of these methods are overloaded and take either a single Char or a String plus an index in the string
Char.IsDigit("1"c)
Char.IsDigit("A123!,0)
Char.IsLetter(" ")
Char.IsLetterOrDigit(" ")
Char.IsLower(" ")
Char.IsUpper(" ")
Char.IsPunctuation(" ")
Char.IsSymbol(" ")
Char.IsWhiteSpace(" ")
Char.IsControl(" ")
string mystring;
mystring = new string(System.Convert.ToChar(90),1);
The Char type represents a Unicode character
If you want to assign a single characeter literal to a Char variable you must use the literal character C to force the string to a Char data type
char myChar;
myChar = "X"C;
myChar = 'A';
It is possible to represent an escape character by prefixing with the backslash character.
myChar = '\n';
myChar = '\u0031';
myChar = '\x0031';
Any Char variables are initialised to ""
Explicit conversion
When assigning a literal character to a Char variable you should yse a trailing "c" to make it explicit that the character must be converted to a Char before assignment.
char myChar;
myChar = "A"c;
The following line will cause a complilation error
char myChar;
myChar = "ABC"c;
Char Structure Methods
GetNumericValue -
GetUnicodeCategory
IsDigit -
IsLetter -
IsUpper -
IsLower -
IsNumber -
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext