top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Define Property in C# ?

+3 votes
277 views
Define Property in C# ?
posted Nov 28, 2014 by Manikandan J

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

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

private double minimumSalary;
public static double MinSalary
{
get
{
return minSalary;
}
set
{
minSalary = 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;

set Method will get triggered and value will be stored in minimumSalary field .

answer Dec 1, 2014 by Shivaranjini
...