Search code examples
c#.net

Struct Implicit Default Constructor vs. Parameterless Constructor


OK, we hear that structcannot have a default parameterless constructor which is fine (http://stackoverflow.com/questions/333829/why-cant-i-define-a-default-constructor-for-a-struct-in-net). But documentation says "Each value type has an implicit default constructor that initializes the default value of that type." from http://msdn.microsoft.com/en-us/library/s1ax56ch.aspx

What's the difference between implicit default constructor and parameterless default constructor right now?


Solution

  • The implicit default constructor is the parameterless constructor which is automatically created by the compiler. The reason you can't create a parameterless constructor is because the default one already exists. I don't know why they chose to do it this way, and why you're not allowed to override it.