In my last job, my manager told me he had read a Microsoft Best Practice guildine regarding the declaration of variables.
Say for example I want to declare an int, a string and a generic type, with their default values:
int intValue = 0;
string stringValue = null;
T genericValue = default(T);
The example above illustrates that all variables have been initialized with their default values, explicitly (and literally), except in the case of the generic type; here we use default(T)
to implicitly initialize the member to it's default value.
The argument that my manager made was that all variables, even in the case where we are initializing them with default values, should be initialised with default(...);
int intValue = default(int);
string stringValue = default(string);
T genericValue = default(T);
In some respects I can see why this approach might be favourable, since the declaration and initialization of variables is consistent.
I want to know if anyone knows of the legitimacy of my managers claim, and in that respect, if you could point me in the direction of the guildine within Microsoft's Best Practice documentation for .NET and C#