The purpose of private setter in c# for property is so you can use auto property feature of Visual Studio
lets say in Visual Studio IDE if you type prop and press tab and you will get the following snippet:
If you wanted to generate a readonly property you can simply type propg and you will get the following snippet:
lets say in Visual Studio IDE if you type prop and press tab and you will get the following snippet:
public int MyProperty { get; set; }
If you wanted to generate a readonly property you can simply type propg and you will get the following snippet:
public int MyProperty { get; private set; }
No comments:
Post a Comment
Your comments are highly appreciated!