Overwriting Default values in C# structs -
For assignment, I must type a tribulous class in a # by using a straight string. There are only three probable triples, right, wrong and unknown, and I have declared them to be read only for free. Like this:
Tribal right, wrong, unknown to read public;
I need my default constructor to provide false Tribool, but I'm not sure how to know about this. I have tried Tribool () {this = False; }
and Tribool () {False; }
But I keep an error in "Structats can not have a clear parameter constructor" error.
Assignment specifies that the default constructor for tribbol should provide wrong tribal. Otherwise, a user should not be able to create any other tribunal I really do not know what to do at this point Any advice would be greatly appreciated. Thank you.
The error is telling you, as you can not be an example constraint for a straight-end instance constructor . See §11.3.8 of the C # 3.0 Language Specifications:
Unlike any class, a straight is not allowed to declare a parameterless instance constructor.
The language provides one that goes as a default constructor for you. This constructor gives the value of the string where the fields have been set to their default values.
Now, what you can do is, the default value of the structure is False
value. I'll leave you details.
Comments
Post a Comment