cat windows-live-writer.md

Private Setters in C#

May 09, 2007

Here’s a little something you probably didn’t know…. In C# you can set access modifiers to your setters and getters for your properties. Like so…

public class MyClass {
  private String _myProperty;

  public String MyProperty {
    get { return _myProperty; }
    private set { _myProperty = value; }
  }
}