Coding | .NET | C♯ | Angular | Ionic | Cordova | :-o

Menu

Quick Properties

Coding had been enormous fun for me and sharing the experience seems to be a surplus. This blog is to focus on C# related tips/routine/quickies but i am sure you would not mind little detours once in a while :-). Intended audience is beginner to intermediate C# devs but i have doubt there is any gauge to really measure the level. So, you are all welcome. Here you go…

Save yourself from defining private fields for each property, c# will do it for you since 3.0.Auto Implemented Properties

public string MyAutoProperty{get; set;}

If you want to control the visibility of get/set you can do so by assigning access modifier to get/set, by default they are public. For example, if you want only the containing class to update this property and make the property available for read only, do following