Data Type - char
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
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
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 ""
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.
myChar = "A"c;
The following line will cause a complilation error
myChar = "ABC"c;
You cannot assign a string expression to a Char variable, instead you must explicitly ask for a conversion from String to Char using the new CChar conversion function
Dim myChar As Char
myChar = CChar(Mid("Sometext",3,1))
You can also use the Chr function to convert a Unicode code to a character
myChar = Chr(65)
Char Structure Methods
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext