It is not compiling when data type in foreach is string. It is compiling when data type in foreach is char. Problem is highlighted.
using System;
class Program
{
static void Main(string[] args)
{
string checkStr = "Address";
foreach (string c in checkStr)
Console.Write(c);
Console.ReadKey();
}
}
Why not compiling
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Sep 8, 2013, 7:38 AM EDT
When you iterate through a string using foreach, you therefore iterate through its individual chars. This is why the foreach control variable needs to be a char, not a string.
Posted Sep 8, 2013, 7:40 AM EDT