The following code converts the string to char array then uses the foreach loop for reading the characters.
usingSystem;
usingSystem.IO;
publicclassForgetCode
{
publicstaticvoidMain()
{
string str = "Coming from Forget Code";
char[] b = newchar[str.Length];
b = str.ToCharArray();
foreach (char c in b)
{
Console.Write(c);
}
}
}
Output:
Coming from Forget Code
Tags for Reading characters in a string using foreach in C#