Tipos de dados de caractere (Visual Basic)
Visual Basic provides character data types to deal with printable and displayable characters. Embora ambos lidam com caracteres Unicode , Char contém um único caractere, enquanto String contém um número indefinido de caracteres.
For a table that displays a side-by-side comparison of the Visual Basic data types, see Resumo de tipo de dados (Visual Basic).
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"
Cada valor possível em um Char ou String variável é um o ponto de código, ou código de caractere, no Unicode conjunto de caracteres. Unicode characters include the basic ASCII character set, various other alphabet letters, accents, currency symbols, fractions, diacritics, and mathematical and technical symbols.
Observação |
---|
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 Caractere tipo de dados (Visual Basic).
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 Tipo de dados de sequência de caracteres (Visual Basic).
Consulte também
Tarefas
Solucionando problemas de tipos de dados (Visual Basic)
Conceitos
Tipos de dados de composição (Visual Basic)
Tipos genéricos no Visual Basic (Visual Basic)
Programação Sem-Tipos no Visual Basic
Caracteres de tipo (Visual Basic)
Outros recursos
Tipos de dados elementares (Visual Basic)