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
No comments:
Post a Comment