There are three types of properties given in C#
1. Read/write (Both getter and setter)
2. Read Only (only getter)
3. Write Only (Only Setter)
1. Read/write (Both getter and setter)
class Employee
{
int
employeeID;
public int EmployeeID
{
get
{ return employeeID; }
set
{ employeeID = value; }
}
}
2. Read Only (only getter)
class Employee
{
int
employeeID;
public int EmployeeID
{
get
{ return employeeID; }
}
}
3. Write Only (Only Setter)
class Employee
{
int
employeeID;
public int EmployeeID
{
get
{ return employeeID; }
set
{ employeeID = value; }
}
}
No comments:
Post a Comment