属性
在C#2.0中属性的定义:
private string _name = "ye";
public string Name
{
get { return _name; }
set { _name = value; }
}
只读
private string _name = "ye";
public string Name
{
get { return _name; }
}
还可以:
private string _name = "ye";
public string Name
{
get { return _name; }
private set { _name = value; }
}(注意:get,set的修饰符至少有一个跟属性的级别相同)
private string _name = "ye";
public string Name
{
get { return _name; }
set { _name = value; }
}
只读
private string _name = "ye";
public string Name
{
get { return _name; }
}
还可以:
private string _name = "ye";
public string Name
{
get { return _name; }
private set { _name = value; }
}(注意:get,set的修饰符至少有一个跟属性的级别相同)