Correct use of C# properties

后端 未结 12 705
生来不讨喜
生来不讨喜 2020-12-16 15:19
private List _dates;

public List Dates
{
    get { return _dates; }
    set { _dates = value; }
}

OR

publi         


        
12条回答
  •  情书的邮戳
    2020-12-16 16:05

    It doesn't matter. The second is just sugar. I always use the second because it's cleaner, but every once in a while I need access to the backing value.

提交回复
热议问题