With O开发者_如何学JAVAption Strict On
:
Dim theLetterA As Char = "A"
returns an error about converting the string "A"
to a Char
.
What is the syntax to enter a Char
literal?
A character literal is entered using a single character string suffixed with a C
.
Dim theLetterA As Char = "A"C
I would use CChar. E.g.:
Dim theLetterA As Char = CChar("A")
Check the MSDN website https://msdn.microsoft.com/en-us/library/s2dy91zy.aspx for details on CChar.
In the case of trying to get a double quote as a character literal, you'll need to use the extra quirky VB format:
Dim theQuote As Char = """"C
Or
Dim theQuote As Char = CChar("""")
精彩评论