V
vooose
Consider
{
bool var;
if(var)
Console.WriteLine("var is true");
}
results in the compilation error
Use of unassigned local variable 'var'
If you make var an instance variable you don't get a compile error as
the variable is effectively 'initialized' to all zeros. Why can't local
variables behave in this manner?
It irritates me that I have to type
bool var=false;
Regards
{
bool var;
if(var)
Console.WriteLine("var is true");
}
results in the compilation error
Use of unassigned local variable 'var'
If you make var an instance variable you don't get a compile error as
the variable is effectively 'initialized' to all zeros. Why can't local
variables behave in this manner?
It irritates me that I have to type
bool var=false;
Regards