Tuesday, August 30, 2005

Setting accessibility for get and set of a Property in c# 2.0

In c# 1.0 there was no way you can set the accessibility qualifiers for get or set inside a property.

C# 2.0 allows you to set different accessibility qualifiers for your get and set of a property. This feature is useful when you want to have different accessibility for your get and set.





public class Employee
{
private string _employeeName;

public string EmployeeName
{
public get { return _employeeName; }
protected set { _employeeName = value; }
}
}



Refrence Chris Breisch

No comments: