string to char array Converting in c#

169 View    Jan 17 2020 11:25PM

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.



public char[] ToCharArray()


public char[] ToCharArray(int startIndex, int length)



string sentence = "CsharpMonster";  

char[] charArr = sentence.ToCharArray(); 

 foreach (char ch in charArr)  





String: Mind Spark

Character array : C s h a r p M o n s t e r