to char array c# code example
Example 1: c# char array to string
using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
char[] char_arr = { 'H', 'e', 'l', 'l', 'o'};
string str = new string(char_arr);
Console.WriteLine("str = " + str);
Console.ReadLine();
}
}
}
Example 2: c# string to character array
string chars = "Array";
char[] letters = chars.toCharArray();
Example 3: making a list of chars in c#
string data = "ABCDEFGHIJ1fFJKAL";
List<char> datalist = new List<char>();
datalist.AddRange(data);
Example 4: c# char array to string
using System;
using System.Text;
namespace Example
{
class Program
{
static void Main(string[] args)
{
char[] char_example = { 'E', 'x', 'a', 'm', 'p', 'l', 'e' };
string charToString = new string(char_example);
Console.WriteLine(charToString);
Console.ReadLine();
}
}
}