Jad*_*ias 2 .net properties automatic-properties c#-3.0
在C#3.0之前,我们这样做:
class SampleClass
{
private int field;
public int Property { get { return this.field } set { this.field = value } }
}
Run Code Online (Sandbox Code Playgroud)
现在我们这样做:
class SampleClass
{
public int Property { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
(看看ma!没有字段!)现在,如果我想自定义Getter或Setter,那么字段必须是C#2.0中的显式字符?
| 归档时间: |
|
| 查看次数: |
270 次 |
| 最近记录: |