显示成员名称不能与他们的封闭类型相同 ,怎么改呀大佬们🙊
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args);
class Program{
static void Main(string[] args){
Student stu = new Student();
stu.Age = -30;
stu.Gender = "女";
stu.Introduce();
Console.ReadKey();
}
}
}
public class Student {
private string name = "张三";
public string Name
{
get { return name; }
}
private int age;
public int Age
{
get { return age; }
set
{
if (value <= 0)
{
Console.WriteLine("年龄不合法...");
}
else
{
age = value;
} }}
public string Gender
{get; set; }
public void Introduce()
{
Console.WriteLine("大家好,我叫" + Name + ",我是" + Gender + "生,今年" + Age + "岁!");
}
}
}