The compiler detected a situation in which a construct was used in some erroneous way or a disallowed operation was tried on a construct. Some common examples include the following:
- A try to instantiate a namespace (instead of a class)
- A try to call a field (instead of a method)
- A try to use a type as a variable
- A try to use an extern alias as a type.
One possible cause is use of parenthesis ‘()’ in Arrays
static void ArrayExample()
{
int[] Marks = new int[5];
string[] Students = new string[5];
for (int i=0;i
{
Console.WriteLine("Student Name: {0} - Marks {1})" , Students(i), Marks(i));
}
}
To resolve this error, replace parenthesis with square brackets
Console.WriteLine("Student Name: {0} - Marks {1}" , Students[i], Marks[i]);
No comments:
Post a Comment