Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Type and identifier are both required in a foreach statement
A foreach statement was poorly formed.
The following sample generates CS0230:
// CS0230.cs
class MyClass
{
public static void Main()
{
int[] myarray = new int[3] {1,2,3};
foreach (int in myarray) // CS0230
{
Console.WriteLine(x);
}
}
}
and the sample below presents the same code, but with no CS0230 error:
class MyClass
{
public static void Main()
{
int[] myarray = new int[3] {1,2,3};
foreach (int x in myarray) // Both type (int) and indentifier (x) are specified
{
Console.WriteLine(x);
}
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.