“does not contain a static 'main' method suitable for an entry point”

后端 未结 7 1286
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 15:21

I can\'t figure what\'s my wrong with my code below.

When I try to compile I get the message:

does not contain a static \'main\' method suitab

相关标签:
7条回答
  • 2020-12-03 15:53

    Every C# program needs an entry point. By default, a new c# Windows Forms project includes a Program class in a Program.cs file:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace StackOverflow6
    {
        static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
        }
    }
    

    You are probably missing this or deleted it.

    0 讨论(0)
提交回复
热议问题