So far, the shortest code I've seen to declare a property that can only be set inside the class I saw:
public T Property {get; private set;}
But what if I want to declare it already with a start value (which is not the default value for this type), how can I do this?
I actually do this:
public T Property {get; private set;} private void Initialize() {Property = Value; }
Another variant:
private T _Property = Value; public property {get {return _Property;}}
But I am wondering if I can only write this with ONE code line, because I will write many of these properties, and I do not want to have a duplicate line for each.
source share