Here is way to convert a given char array into string. Just pass the array into string constructor and it will automatically convert into string.
using System;
namespace MyApp
{
class array_to_string_class
{
static void Main()
{
char[] array_var = new char[16];
array_var[0] = 'S';
array_var[1] = 'o';
array_var[2] = 'f';
array_var[3] = 't';
array_var[4] = 'w';
array_var[5] = 'a';
array_var[6] = 'r';
array_var[7] = 'e';
array_var[8] = ' ';
array_var[9] = 'T';
array_var[10] = 'e';
array_var[11] = 's';
array_var[12] = 't';
array_var[13] = 'i';
array_var[14] = 'n';
array_var[15] = 'g';
string str = new string(array_var);
Console.WriteLine(str);
Console.Read();
}
}
}
No comments:
Post a Comment