convert string array 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# 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();
}
}
}
Example 3: how to turn a string in a char list c#
string sentence = "Mahesh Chand";
char[] charArr = sentence.ToCharArray();
foreach (char ch in charArr)
{
Console.WriteLine(ch);
}
Example 4: how to make a string a list of characters c#
string scentence = "Hi there";
char[] charArr = scentence.ToCharArray()
Example 5: how to turn a string in a char list c#
string str= "hello";
List<char> listString = str.ToList();
listString.ForEach(s=> Console.WriteLine(s));
Console.WriteLine(listString);