Click here to Skip to main content
15,666,947 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Please could you clarify abow question.

A field is a variable, a property is a syntactic sugar for two methods - a getter and a setter - which get called when you access the property instead of accessing the content of the variable directly.

The advantage of this is two-fold: firstly it allows the containing class to hide the internal implementation of details from the outside world, presenting the property as a "simple variable" when it can in fact be a complex calculation, or based on a control, etc.
Secondly, it allows the property to be "read only", or "write only" as far as the outside world is concerned which is not possible with fields.

Basically, if the outside world needs to know about a value, it should be a property: fields should never be exposed as public objects.

For a fuller description, refer to MSDN[^] and Google[^]
Share this answer
Kindly go through the below link
Difference between Properties and Fields
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900