Difference between "Convert.toString" and ".toString()" in VB.Net?

By James J

Main difference between "Convert.toString" & ".toString()" with one example...

int intval =0;
MessageBox.
Show(intval.ToString());
MessageBox.
Show(Convert.ToString(intval));

We can convert the integer “intval” using “intval.ToString()” or “Convert.ToString” so what’s the difference.

The basic difference between them is “Convert” function handles NULLS while “intval.ToString()” does not it will throw a NULL reference exception error.

So as good coding practice using Convert” is always safe.

Difference between "Convert.toString" and ".toString()" in VB.Net?  (1054 Views)