Why won't anyone accept public fields in C#?

Posted by Dmitri Nesteruk on Stack Overflow See other posts from Stack Overflow or by Dmitri Nesteruk
Published on 2009-01-26T17:31:46Z Indexed on 2010/05/31 19:13 UTC
Read the original article Hit count: 363

Filed under:
|
|

Seems like every C# static analyzer wants to complain when it sees a public field. But why? Surely there are cases where a public (or internal) field is enough, and there is no point in having a property with its get_ and set_ methods? What if I know for sure that I won't be redefining the field or adding to it (side effects are bad, right?) - shouldn't a simple field suffice?

© Stack Overflow or respective owner

Related posts about c#

Related posts about property