Correct use of C# properties

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

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

OR

publi         


        
12条回答
  •  失恋的感觉
    2020-12-16 15:56

    The two are compiled roughly the same way (I don't know that the backing field's name would specifically be the same, but they'd be functionally equivelant).

    IIRC, the ability to do Automatic Properties (public List Dates {get; set;}) was added in either .NET 3.0 or 3.5.

提交回复
热议问题