Properties
Properties
}
}
• Explanation: In above you can see that public members of
class stud can be accessed by class Demo1 and using the
object "obj" of stud it can provide the values to the
members rn and name .
Using Properties
What is Property ?
• Properties are the special type of class members
that provides a flexible mechanism to read,
write, or compute the value of a private field.
• Example
public string Name
{
get{return name;}
set{name =value;}
}
• A get property accessor is used to return the
property value, and a set property accessor is
used to assign a new value.