private List<Date> _dates;
public List<Date> Dates
{
get { return _dates; }
set { _dates = value; }
}
OR
public List<Date> Dates
{
get;
set;
}
I have always used the former, is that incorrect or bad practice? It never occurred to me that I could just use the second option. I do like having my encapsulated variables to begin with an underscore so I can distinguish them from method parameters. And I've just always done it that way.
Is it possible that using the first option would result in an extra List<Date>
object being instantiated and then the whole of _dates
being replaced with value
, or is it more intelligent than that?
Also, which is the most prominent in industry or is it totally subjective?