Convert string to char array in C#

How to convert a string to a char array using C#. The ToCharArray method of the string class converts a string to a character array

The following code snippet creates a string into a char array.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace StringtoCharArray
class Program
static void Main(string[] args)
string s;
Console.WriteLine(“enter string:“);
s = Console.ReadLine();
char[] ch = new char[s.Length];
ch = s.ToCharArray();
for (int i = 0; i < s.Length; i++)

Now Run Program and check output


Leave a Reply

Your email address will not be published.