c# - ToString on null string -


why second 1 of these produce exception while first 1 doesn't?

string s = null; messagebox.show(s); messagebox.show(s.tostring()); 

updated - exception can understand, puzzling bit (to me) why first part doesn't show exception. isn't messagebox, illustrated below.

eg :

string s = null, msg; msg = "message " + s; //no error msg = "message " + s.tostring(); //error 

the first part appears implicitly converting null blank string.

because cannot call instance method tostring() on null reference.

and messagebox.show() implemented ignore null , print out empty message box.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -