"不含适合的切入点&QUOT一个静态的'主'的方法; [英] "does not contain a static 'main' method suitable for an entry point"
本文介绍了"不含适合的切入点&QUOT一个静态的'主'的方法;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白什么是我的错我的低于code。
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 suitable for an entry point.
这是我的code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RandomNumberGenerator
{
public partial class Form1 : Form
{
private const int rangeNumberMin = 1;
private const int rangeNumberMax = 3;
private int randomNumber;
public Form1()
{
randomNumber = GenerateNumber(rangeNumberMin, rangeNumberMax);
}
private int GenerateNumber(int min,int max)
{
Random random = new Random();
return random.Next(min, max);
}
private void Display(object sender, EventArgs e)
{
switch (randomNumber)
{
case 1:
MessageBox.Show("A");
break;
case 2:
MessageBox.Show("B");
break;
case 3:
MessageBox.Show("C");
break;
}
}
}
}
有人可以告诉我在哪里,我已经错了。
Can someone please tell me where I've gone wrong.
推荐答案
每一个C#程序需要一个切入点。默认情况下,一个新的C#Windows窗体项目包括一个中的Program.cs文件程序
类:
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.
这篇关于&QUOT;不含适合的切入点&QUOT一个静态的'主'的方法;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文