0
You can't define a parameterless constructor for a struct because the system ALWAYS provides one by default.
This initializes all the struct's fields to their default values (zero for numeric types, false for bool, '\0' for char, null for string and other reference types). For example, this line:
int i = new int();
sets i equal to 0.
0
Hi Gomathi,
The .NET Common Language Runtime (CLR) does not guarantee that parameterless constructors will be called. If structs were permitted to have default, parameterless constructors, the implication would be that default constructors would always be called. Yet, the CLR makes no such guarantee.
For instance, an array of value types will be initialized to the initial values of its members—i.e., zero for number type primitive members, null
for reference types, and so forth—and not to the values provided in a default constructor. This feature makes structs perform better; because, constructor code need not be called.
So, requiring that a constructor contain a minimum of one parameter reduces the possibility that a constructor will be defined which is expected to be called every time the struct type is built.
Thanks,
Prasant
0
Although the CLR allows it, C# does not allow structs to have a default parameterless constructor. The reason is that, for a value type, compilers by default neither generate a default constructor, nor do they generate a call to the default constructor. So, even if you happened to define a default constructor, it will not be called and that will only confuse you. To avoid such problems, the C# compiler disallows definition of a default constructor by the user.
0
Because Struct are value types. The C# doesn't allows value types to have parameterless constructors, but CLR allows. Struct members are automatically initialized to their default values.