c# string to char

56

c# string to char -

//Creates char-array out of the string

string str = "Hello";
char[] characters = str.ToCharArray();

//if string is only one letter:

string str = "A";
char character = char.Parse(str);

//or

string str = "A";
char character = str.ToCharArray()[0];

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);  
}   

Comments

Submit
0 Comments