The primitive value type of C #, for example int, is a structure. So why intnot initialized? I think this should be the default constructor. On the other hand, the user structure is fine.
In the following code
struct STRCT { }
class Program
{
static void Main(string[] args)
{
STRCT strct;
strct.Equals(8);
strct.GetHashCode();
strct.GetType();
strct.ToString();
int i;
i.Equals(8);
i.GetHashCode();
i.GetType();
i.ToString();
}
}
while the first 5 lines of code are in order from the C # compiler view, the following 5 lines of code generate a compilation error:
use of an unassigned local variable
Please explain why? From my point of view, both types are structures and should have the same behavior.
source
share