initializing int field with 0 is redundant. really?

class Foo
{
     int _bar = 0; //initializing field by default value is redundant warning

     Foo()
     {
          Console.Write(_bar);
     }
}


i have an objection to that behavior of Resharper.

is it really better to use implicit initialization over explicit?

to be honest, i don't know, whether C# standart tells something about what values uninitialized fields have by default (and whether these defaults are subject to change in future). but i can't understand, why this initialization is redundant (and with warning! it is not even suggestion or hint).

on the contrary to that, i think there have to be warning when one is using uninitialized variable, but resharper encourages exactly opposite..



p.s. am i just blind or there is no "code" formatting option in this editor? pretty strange for forum for programmers ^__^

Please sign in to leave a comment.