To understand both the methods let's take an example:
int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));
Here both the methods are used to convert the string but the basic difference between them is: "Convert" function handles NULLS, while "i.ToString()" does not it will throw a NULL reference exception error. So as good coding practice using "convert" is always safe.
Let's see another example:
string s;
object o = null;
s = o.ToString();
//returns a null reference exception for s.
string s;
object o = null;
s = Convert.ToString(o);
//returns an empty string for s and does not throw an exception.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Sunil jadhavPosted Mar 19, 2019, 9:35 AM
Nice example.Clear to understand. Thanks for sharing...
Rajesh KumarPosted Dec 25, 2018, 12:52 PM
Nice article thanks for sharing...............