A question about initialization of native types
I would like to do this:
public class Foo
{
int x = null;
// constructor
public Foo
{
x = 1;
}
}
but assigning null to x does not work since null is not an int
This works:
public class Foo
{
int x = 1;
// constructor
public Foo
{
}
}
but I don't like that x is not initialized in the constructor.
Stepping thru the debugger at the point of the constructor, it does jump up to the int x = 1; line, as if it were actually in the constructor.
Is this the best one can do?
This doesn't apply to actual classes because they can be initialized to null.