Question:

Define Property in C# ?

Answer:

Properties are a type of class member, that are exposed to the outside world as a pair of Methods. For example, for the static field Minsalary, we will Create a property as shown below.

 

private double minimumSalary;
public static double MinSalary
{
 get
 {
   return minimumSalary;
 }
 set
 {
   minimumSalary = value;
 }
}

So when we execute the following lines code

double minSal = Employee.MinSalary;

get Method will get triggered and value in minimumSalary field will be returned. When we execute,

Employee. MinSalary = 3000;

 


Keywords:

© 2017 QuizBucket.org