Various method to convert Char to String using VB.NET

In this article I will explain, how to convert Unicode character to its equivalent string.
  • 2377

You can not implicitly convert the value of specified Unicode character to its equivalent string representation. You need to convert a char value to a string reference in your program. I have used many way to convert char to string in this article. Most have got a problem with parsing char to string now you can use any below method to convert char to string that get rid of from this problem.


There are several ways to do this, with the clearest being the ToString virtual method.


Module Module1
    Sub Main()
        Dim Chr As Char = "W"c
        Dim myString As New String(Chr, 1)
        Console.WriteLine(vbTab & myString)
        Dim Chr2 As Char = "X"c
        Dim myString1 As String = Chr2.ToString()
        Console.WriteLine(vbTab & myString1)
        Dim Chr3 As Char = "Y"c
        Dim myString2 As String = Convert.ToString(Chr3)
        Console.WriteLine(vbTab & myString2)
        Dim Chr4 As Char = "Z"c
        Dim myString3 As String = New [String](New Char() {Chr4})
        Console.WriteLine(vbTab & myString3)
    End Sub
End Module




More Articles

© 2020 DotNetHeaven. All rights reserved.