- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are accessors of properties in C#?
Properties are an extension of fields and are accessed using the same syntax. They use accessors through which the values of the private fields can be read, written or manipulated.
The accessor of a property contains the executable statements that helps in getting (reading or computing) or setting (writing) the property.
Let us see an example of properties in C#.
Example
Declare a code property of type string.
public string Code { get { return code; } set { code = value; } }
In the same way, declare Age property of type as in the following code snippet.
Example
public int Age { get { return age; } set { age = value; } }
Advertisements