Why do C# automatic properties not support default values like VB 2010?

Posted by Rob van Groenewoud on Stack Overflow See other posts from Stack Overflow or by Rob van Groenewoud
Published on 2010-04-13T08:22:05Z Indexed on 2010/04/13 8:43 UTC
Read the original article Hit count: 328

Looking at the new VB 2010 features, I stumbled upon support for Auto-Implemented Properties.

Since I'm working with C#, this seemed quite familiar, but I noticed that VB did add a feature I would love to have in C#: setting a arbitrary default value for the auto-implemented property:

Auto-implemented property with default value

I really like the clean usage of auto-properties in C#. This would save us the effort of introducing a backing field and hooking it up to the property everytime we simply need a default value, thereby cluttering up the code unnecessarily.

I was wondering why this wasn't introduced in C# as well? What could be the rationale for not doing this? Is a syntax discussion going on, or are there technical limitations to implementing this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about vb.net