Re: struct initialization
Re: struct initialization
It's not a question wether to use struct or class.
I'd just like to know why struct gives me a compile error and class doesn't ?
Re: struct initialization
To find the reason, type the full error into a bing or google search, then read a few replies.
from http://msdn.microsoft.com/en-us/library/w29h4276.aspx
Quote:
All fields in a struct have to be assigned by a constructor before the constructor can call a method in the struct.
Re: struct initialization
Btw, you can get rid of this error by calling : this() in the constructor.
Code:
public FullName(string First)
: this()
{
...
}
Re: struct initialization
I had already figured out the :this() solution ;)
Thanks for your explanation on the CS0188 , the specific struct behavior is clear to me now !
Re: struct initialization
Hopefully, the big tip from this post is this:
Quote:
To find the reason, type the full error into a bing or google search, then read a few replies.