Properties are used to access or modify the private members (private variables).
We can say it’s a mediator between private variables and initialization.
Below we have two private members one is private string name and private string address.
- I am creating an object for talents class which is “t” and constructor will initialize id name and course name into public int id=420 and public string coursename =java.
Here “this” operator is used to differentiate with ordinary variables and class variables.
- I cannot initialize directly into private variables so I go for properties concept. If you declare {get; set;} directly its initialize the values. Above I have initialize the address with its.
- Above I have initialize the name with murali.