What is the difference between a property with a omitted setter and a property with a private setter?
public string Foo { get; private set; }
vs
public string Foo { get; }
In C# 6, get; only properties are only settable from the constructor. From everywhere else, it is read-only.
get;
A property with a private set; can be set from everywhere inside that class.
private set;
2.1m questions
2.1m answers
60 comments
56.9k users