编译器错误 CS0017Compiler Error CS0017

程序“输出文档名称”定义了多个入口点。Program 'output file name' has more than one entry point defined. 请使用 /main 进行编译,以指定包含入口点的类型。Compile with /main to specify the type that contains the entry point.

一个程序只能有一个 Main 方法。A program can only have one Main method.

若要解决此错误,可以删除代码中的所有 Main 方法(除了一个方法除外),也可以使用 -main 编译器选项来指定想要使用的 main 方法。To resolve this error, you can either delete all Main methods in your code, except one, or you can use the -main compiler option to specify which Main method you want to use.

下面的示例生成 CS0017:The following sample generates CS0017:

// CS0017.cs  
// compile with: /target:exe  
public class clx  
{  
   static public void Main()  
   {  
   }  
}  
  
public class cly  
{  
   public static void Main()   // CS0017, delete one Main or use /main  
   {  
   }  
}