private int age=18;
private string name="Klento";
private string hobby="drving";
public int Age
{
get { return age; }
set
{
if (value > 0 && value < 100)
{
age = value;
}
else
{
age = 18;
}
}
}
public string Name
{
get { return name; }
}
public string Hobby
{
get { return hobby; }
set
{
hobby = value;
}
通过接口限制用户对数据的更改