संपादित करें

इसके माध्यम से साझा किया गया


Character Data Types (Visual Basic)

Visual Basic provides character data types to deal with printable and displayable characters. While they both deal with Unicode characters, Char holds a single character whereas String contains an indefinite number of characters.

For a table that displays a side-by-side comparison of the Visual Basic data types, see Data Types.

Char Type

The Char data type is a single two-byte (16-bit) Unicode character. If a variable always stores exactly one character, declare it as Char. For example:

' Initialize the prefix variable to the character 'a'.
Dim prefix As Char = "a"

Each possible value in a Char or String variable is a code point, or character code, in the Unicode character set. Unicode characters include the basic ASCII character set, various other alphabet letters, accents, currency symbols, fractions, diacritics, and mathematical and technical symbols.

Note

The Unicode character set reserves the code points D800 through DFFF (55296 through 55551 decimal) for surrogate pairs, which require two 16-bit values to represent a single code point. A Char variable cannot hold a surrogate pair, and a String uses two positions to hold such a pair.

For more information, see Char Data Type.

String Type

The String data type is a sequence of zero or more two-byte (16-bit) Unicode characters. If a variable can contain an indefinite number of characters, declare it as String. For example:

' Initialize the name variable to "Monday".
Dim name As String = "Monday"

For more information, see String Data Type.

See also