这些代码错在哪里
using System;
namespace Shape
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class demo
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
Circle yuan = new Circle();
yuan.getcolor();
yuan.getArea();
Square chang = new Square();
chang.getcolor();
chang.getArea();
}
}
abstract class Shape
{
int _color;
public void getcolor()
{
_color=int.Parse(Console.ReadLine());
Console.WriteLine(_color);
}
public abstract void getArea();
}
class Circle:Shape
{
int _radius=19;
int _sideLen=10;
public override void getArea()
{
Console.WriteLine(_radius*_sideLen);
}
}
class Squarea:Shape
{
int _radius=11;
int _sideLen=44;
public override void getarea()
{
Console.WriteLine(_radius*_sidelen);
}
}
}
------解决方案--------------------//请参考注释,并请提高看懂出错信息的能力
using System;
namespace Shape
{
//类名规范为大写
class Demo
{
static void Main(string[] args)
{
Circle yuan = new Circle();
yuan.getcolor();
yuan.getArea();
Square chang = new Square();
chang.getcolor();
chang.getArea();
}
}
abstract class Shape
{
int _color;
public void getcolor()
{
_color = int.Parse(Console.ReadLine());
Console.WriteLine(_color);
}
public abstract void getArea();
}
class Circle : Shape
{
int _radius = 19;
int _sideLen = 10;
public override void getArea()
{
Console.WriteLine(_radius * _sideLen);
}
}
//类名拼错Squarea--> Square
class Square : Shape
{
int _radius = 11;
int _sideLen = 44;
//方法getarea--> getArea
public override void getArea()
{
//sidelen --> sideLen
Console.WriteLine(_radius * _sideLen);
}
}
}
------解决方案--------------------没有声明名字空间