Is it possible, using C# Automatic Properties, to create a new instance of an object?
in C# I love how I can do this:
public string ShortProp {get; set;}
is it possible to do this for objects like List that first need to be instantiated?
ie:
List<string> LongProp = new List<string>();
public List<string> LongProp {
get {
return LongProp ;
}
set {
LongProp = value;
}
}
You can initialize your backing field on the constructor:
But… are you sure about making this list a property with a public setter? I don’t know your code, but maybe you should expose less of your classes’ properties: