If we initialization of variable while declaring it then compiler generates the initialization code at beginning of each constructor. If there is no constructor then compiler generates the default constructor for that class. This initialization code execute before base class constructor and execute in order they declare.
Initialization of member variable while declaring it get rid of the problem of put member variable initialization code in constructor.
If you have to initialization your variable null then do do this because it will automatically initialize to null variable is not initialize.
Only do initialization of those variables which you want to initialize in constructor. If you have to initialize your variable somewhere else then previous initialize object will going to collect by the garbage.
If you do initialization while declaring the variable then you can not catch any exception if there is any. In that case use constructor.
To initialize static variable static constructor are the best place. Static constructor execute before any other method, properties or data member access first time and static constructor are called by CLR so they will be always parameter less.
I am not a native English speaker nor well trained. Please feel free to comment on the post for any mistake related to spellings, grammar etc, so that I can improve it based upon your suggestion.
Like this post → follow me on twitter @imaheshsingh
Stumble It! Share on Facebook! Tweet it!
Tags: C#, c-sharp, constructor, static constructor