How to convert a char array to stringĀ in c# or vb.net?

 

Sample C#

char[] myCharArray = { 'H', 'e', 'l', 'l', 'o', ',', 'W', 'o', 'r', 'l', 'd' };
string newString = new string(myCharArray);

Sample VB.NET

Dim myCharArray As Char() = {"H", "e", "l", "l", "o", ",", "W", "o", "r", "l", "d"}
Dim newString As New String(myCharArray)

For more informations take a look at the String Class Constructor’s in the msdn.

One thought on “How to convert a char array to string”

Leave a Reply