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
Post a Comment