vb.net char() to String

Hi:

How do you cast a char array to a String?  Here's what I do:

Dim string2 As String
Dim string1 As String = "hello"
Dim charArray() As Char = string1.ToCharArray()
string2 = Cstr(charArray)

I am getting "A first chance exception of type 'System.InvalidCastException' occurred..." error message.

I tried: string2 = New String(charArray)
Same deal.

Please help.
sdc248Asked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
You can do:

    string2 = Convert.ToString(charArray)
0
 
CodeCruiserCommented:
Another option

string2 = charArray.ToString
0
 
sdc248Author Commented:
charArray.ToString gives me "System.Char()"
0
All Courses

From novice to tech pro — start learning today.