Conversion of Character array into String using VB.NET

First declare and assign value to Char () array and then, Invoke the New String constructor and then give Char array identifier reference in argument slot.
  • 8855
 

In this article I am going to convert Char () array to String instances in the vb.net. It is too simple you can easily convert Char () array to String. First declare and assign value to Char () array. Char keyword is used to declare a Unicode character in the specific range. Second, Invoke the New String constructor and then give Char array identifier reference in argument slot. In first code I am converting character array to string { Dim str1 As New String (chararray) } 


Untitleddsfsdfsd1.png


and in second i am making comparison with character array and string.
Dim
str2 As New String(chararray)      
Console.WriteLine(str2 = "My name is Clark")

Code
Module Module1 
    Sub Main()
        Dim chararray As Char() = New Char(15) {}
        chararray(0) = "M"c
        chararray(1) = "y"c
        chararray(2) = " "c
        chararray(3) = "n"c
        chararray(4) = "a"c
        chararray(5) = "m"c
        chararray(6) = "e"c
        chararray(7) = " "c
        chararray(8) = "i"c
        chararray(9) = "s"c
        chararray(10) = " "c
        chararray(11) = "C"c
        chararray(12) = "l"c
        chararray(13) = "a"c
        chararray(14) = "r"c
        chararray(15) = "k"c
        Dim str1 As New String(chararray)
        Console.WriteLine(str1)
        Dim str2 As New String(chararray)
        Console.WriteLine()
        Console.WriteLine(str2 = "My name is Clark")
        Console.ReadLine()
    End Sub
End
Module

Output

chararcter aray.gif

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.