Use of unassigned local int variable

Viewed 26

Why does the following code not output 0, but instead results in the following compilation error:

"CS0165: Use of unassigned local variable 'i'"

int i;

Console.WriteLine(i);

It was my understanding that an unassigned integer variable defaults to 0 and thus the output should be 0.

0 Answers
Related