How do you declare a char literal in Visual Basic.NET?

With Option Strict On :

 Dim theLetterA As Char = "A" 

returns an error about converting string "A" to Char .

What is the syntax for inputting a Char literal?

+67
literals
Jul 30 '10 at 19:45
source share
2 answers

A character literal is entered using a single character string labeled C

 Dim theLetterA As Char = "A"C 
+128
Jul 30 '10 at 19:46
source share

I would use CChar. For example:.

  Dim theLetterA As Char = CChar("A") 

For more information on CChar, check out the MSDN website at https://msdn.microsoft.com/en-us/library/s2dy91zy.aspx .

+4
Mar 03 '15 at 19:25
source share



All Articles