Javatpoint Logo
Javatpoint Logo

C# Properties

C# Properites doesn't have storage location. C# Properites are extension of fields and accessed like fields.

The Properties have accessors that are used to set, get or compute their values.

Usage of C# Properties

  1. C# Properties can be read-only or write-only.
  2. We can have logic while setting values in the C# Properties.
  3. We make fields of the class private, so that fields can't be accessed from outside the class directly. Now we are forced to use C# properties for setting or getting values.

C# Properties Example


Employee Name: Sonoo Jaiswal

C# Properties Example 2: having logic while setting value


Employee Name: Sonoo JavaTpoint

C# Properties Example 3: read-only property


No. of Employees: 3
Next TopicC# Inheritance

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials

B.Tech / MCA