Properties Fields का Extension हैं और इन्हें Same Syntax का उपयोग करके Access किया जाता है। ये Accessors का उपयोग करते हैं जिनके माध्यम से Private Fields के Values को Read, Write या Manipulate किया जा सकता है।
Property का Accessor उन Executable Statements को Contain करता है जो Property को Get (Read या Compute) या Set (Write) करने में Help करते हैं।
आइए C# में Properties का एक Example देखते हैं।
Example
String Type का Code Property Declare करें।
public string Code { get { return code; } set { code = value; } }इसी तरह, Age Property को Type के रूप में Declare करें जैसा कि निम्न Code Snippet में है।
Example
public int Age { get { return age; } set { age = value; } }