Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Struct Implicit Default Constructor vs. Parameterless Constructor

Tags:

c#

.net

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?

like image 843
Tarik Avatar asked Jun 03 '12 01:06

Tarik


Video Answer


1 Answers

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.

like image 54
HypnoToad Avatar answered Nov 15 '22 04:11

HypnoToad