无效的表达式项“term”
编译器在表达式中检测到无效项。 此错误可能是由于缺少预期表达式,导致后续标记错误地被分析为表达式,或者表达式中使用无效构造。 常见根本原因包括不匹配的标记、缺少分号或多余的分隔符。
下面的示例生成 CS1525:
// CS1525.cs
class MyClass
{
public static void Method(int number) {}
public static void Main()
{
int i = 0;
i = i + 'c' + 1 + (2); // OK
i = i + void + throw; // CS1525, these keywords are not valid in this expression
Method(123,); // CS1525, excess trailing comma
goto EmptyLabel;
EmptyLabel: // CS1525, empty label
// Add something here to resolve the error, for example:
// System.Console.WriteLine("Hello!");
}
}