热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_56655643
艾哥的小老弟
4 年前
trueweixin_56655643

显示成员名称不能与他们的封闭类型相同 ,怎么改呀大佬们🙊

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 + "岁!");
}
}
}

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
这个有错吗?
立即登录