日期:2014-05-18 浏览次数:20871 次
private int num; //只读属性 public int Num { get { return this.num; } } private string str; //只写属性 public string Str { set { this.str = value; } } private double doub; //读写属性 public double Doub { get { return this.doub; } set { //有条件的写,如果大于0,返回value,否则返回0 if (value >= 0) { this.doub = value; } else { this.doub = 0; } } }