in C#, why do I see there's a zero stored in my int variable when I declare it, but still get an error saying I should initialize it?

Viewed 2494

in C#, if i do something like:

int x;

then hit F10, I see that there's a zero stored in x.

but when i try to use x, it tells me that i should initialize it .. why is that ? there's supposed to be a zero there, right ?

the same thing is also true about arrays, so:

int[]a = new int[5];

if we F10 that, we'll see that all the ints in there are zeros..

What's going on ? and why should i ever MUST initialize a variable in C# unlike in C++ ?

5 Answers
Related