Alex Rivera | Logout

What is the difference between a field and a property?

Asked 2008-11-17T08:41:38.037
1602

In C#, what makes a field different from a property, and when should a field be used instead of a property?

Edit
Report

1 Answer

5

Also, properties allow you to use logic when setting values.

So you can say you only want to set a value to an integer field, if the value is greater than x, otherwise throw an exception.

Really useful feature.

answered 2008-11-17T10:46:29.597

Your Answer