VB.Net Tutorial/Data Type/Char

Материал из VB Эксперт
Перейти к: навигация, поиск

Char Declaration

public class Test
   public Shared Sub Main
        Dim Char1 As Char = "A"
        Dim Char2 As Char = CChar("A")
        Dim Char3 As Char = "A"c
        Console.WriteLine(Char1 & " " & Char2 & " " & Char3)
   End Sub
   
End class
A A A

Declare Char using "c"

Imports System.Collections
public class ConvertToString
   public Shared Sub Main
               Dim c As Char = "A"c
               Dim s As String = ""
               s = CType(c, String)
               Console.WriteLine(s)
   End Sub
End class
A

Use CType to convert Char to String

Imports System.Collections
public class ConvertToString
   public Shared Sub Main
               Dim c As Char = "A"c
               Dim s As String = ""
               s = CType(c, String)
               Console.WriteLine(s)
   End Sub
End class
A