ARTICLE

convert Char() array to String vb.net

Posted by Sapna Articles | Visual Basic Language July 03, 2011
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.
 
Reader Level:

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) } 


Untitleddsfsdfsd.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

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Diagram
Become a Sponsor