public class myRect
{
private System.Drawing.Point p0;
private int a, b;
public myRect(int aa, int bb, System.Drawing.Point p)
{
a = aa; b = bb; p0 = p;
}
public int Area() //求面积
{ return(a * b); }
public int round() //求周长
{ return(2 * (a + b)); }
public void move(int dx, int dy) //移动顶点
{
p0.X += dx;
p0.Y += dy;
}
}
源代码是这样的 调试之后出现不包含适合于入口点的静态“Main”方法。
求大神指教,本人新手渣子一个
缺少了主函数main
代码如下
class Program
{
public class myRect
{
private System.Drawing.Point p0;
private int a, b;
public myRect(int aa, int bb, System.Drawing.Point p)
{
a = aa; b = bb; p0 = p;
}
public int Area() //求面积
{ return (a * b); }
public int round() //求周长
{ return (2 * (a + b)); }
public void move(int dx, int dy) //移动顶点
{
p0.X += dx;
p0.Y += dy;
}
}
static void Main(string[] args)
{
Point p = new Point(5, 5);
myRect m = new myRect(5, 2, p);
Console.WriteLine(m.round());
Console.ReadKey();
}
}
可能是以下原因
1.public static void Main() 主函数的Main的M要大写
2.打开解决方案资源管理器,右键-->属性
打开之后,在应用程序--->输出类型中选择--类库即可
是因为你的程序里面没有static void Main这样一个入口点,你看下Program.cs是不是被你修改或者删掉了?里面就有static void Main()这个入口函数的。