回复 楼主 tremere
public enum Sex
{
Male=0,
Female=1,
}
public partial class StudentInfo
{
int _id;
string _name;
Sex _gender;
int _age;
public int ID
{
get{return _id;}
set{_id=value;}
}
public string Name
{
get{return _name;}
set{_name=value;}
}
public Sex Gender
{
get{return _gender;}
set{_gender=value;}
}
public int Age
{
get{return _age;}
set{if(value<1){_age=1;}else{_age=value;}}
}
public void sayHello()
{
Console.WriteLine("我是一名学生,我的名字是"+_name);
}
public override string ToString()
{
return string.Format("ID:{0},Name:{1},Gender:{2},Age:{3}",_id,_name,_gender,_age);
}
}
获得学号,获得姓名,获得年龄,和修改年龄的5个方法
读取/设置相应属性即可.
可以借鉴一下