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

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

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