Compiler Error CS1001

应输入标识符

未提供标识符。标识符是您提供的类、结构、命名空间、方法、变量等的名称。

下面的示例声明一个简单的类,但没有为类指定名称:

//cs1001.cs
public class              //CS1001
    {
        public int Num {get; set;}
        void MethodA(){}
    }

下面的示例之所以会生成 CS1001,原因是在声明枚举时必须指定成员:

// CS1001.cs
public class clx
{
   enum Colors : int
   {
      'a', 'b' // CS1001, 'a' is not a valid int identifier
       // The following line shows examples of valid identifiers:
       // Blue, Red, Orange
   };

   public static void Main()
   {
   }
}

即使编译器不使用参数名(例如,在接口定义中),也需要参数名。需要这些参数,以便使用接口的程序员能够对参数的含义有所了解。

// CS1001-2.cs
// compile with: /target:library
interface IMyTest
{
   void TestFunc1(int, int);  // CS1001
   // Use the following line instead:
   // void TestFunc1(int a, int b);
}

class CMyTest : IMyTest
{
   void IMyTest.TestFunc1(int a, int b)
   {
   }
}

请参阅

语句、表达式和运算符(C# 编程指南)

类型(C# 编程指南)