Sunday 25 August 2013

Diffrence b/w Convert.ToString() and .ToString()

Diffrence b/w Convert.ToString() and .ToString()



.ToString()………….
.ToString() does not handle null value.
string s = null;
      
 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "<script> alert('" + s.ToString() + "')</script>", false);

It’s Generates Error as Given Below:-
NullReferenceException was unhandled by user code


Convert.ToString ()

It’s handle null value.
string s = null;
      
 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "<script> alert('" +  Convert.ToString(s) + "')</script>", false);

It does Not  Generates Error






0 comments: