Sunday, 27 August 2017

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(thisthis.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(thisthis.GetType(), """<script> alert('" +  Convert.ToString(s) + "')</script>"false);

It does Not  Generates Error

No comments:

Post a Comment

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...