In this post i will show you what is the main difference between Convert.ToString and .ToString() method.
The basic difference between them is “Convert.ToString(variable)” handles NULL values even if variable value become null but “variable.ToString()” will not handle NULL values it will throw a NULL reference exception error. So as a good coding practice using “convert” is always safe.
//Returns a null reference exception for Name. string Name; object i = null; Name= i.ToString(); //Returns an empty string for name and does not throw an exception. string Name; object i = null; Name = Convert.ToString(i);
Do you want to hire us for your Project Work? Then Contact US.