更新时间:2022-05-04 05:05:53
自动属性被用于在没有额外的逻辑,需要在属性访问器。
声明看起来是这样的:
Automatic Properties are used when no additional logic is required in the property accessors.
The declaration would look something like this:
public int SomeProperty {get; set;}
他们只是语法糖,所以你不会需要编写以下更加漫长code:
They are just syntactic sugar so you won't need to write the following more lengthy code:
private int _someField;
public int SomeProperty
{
get { return _someField;}
set { _someField = value;}
}