Skip to main content

Posts

Showing posts with the label Properties in C#

Class Properties in C# Explained

Properties in C# Property  is an extension of class  variable   and it provides a mechanism to read, write or change the value of the class variable without affecting the external way of accessing it.   Properties can contain one or two code blocks called  accessors  and those are called a  get  accessor and  set  accessor in C#. By using  get  and  set  accessors, we can change the internal implementation of class  variables   and expose it without affecting the external way of accessing it.   Generally, in object-oriented programming languages like C# you need to define fields as  private , and then use properties to access their values in a  public  way with  get  and  set  accessors.   The following is the syntax of defining a  property  with  get  and  set  accessor in C#.     <access...