c# - Explicit assignment of null -


string s1; string s2 = null;  if (s1 == null) // compile error if (s2 == null) // ok 

i don't understand why explicit assignment needed. whats difference between null variable , unassigned variable? assumed unassigned variables assigned null runtime/compiler anyway. if they're not null, they?

unassigned members automatically initialized default values (which null reference in case string).

unassigned local variables not assigned value , trying access possibly unassigned variable give compile error.


Comments

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

xslt - Umbraco and EXSLT sets do not work -

php - How can I merge Nodes & Webform Submissions into instances of one general Content Type in Drupal 6? -