Skip to main content
Difference between Convert.ToString() and ToString()

Difference between Convert.ToString() and ToString()

In this post, we will explain the difference between .ToString() and Convert.ToString() methods in C#.

The basic difference between them is “Convert.ToString()” handles NULL values while “.ToString()” doesn’t. Which means if the variable being passed to Convert.ToString() is NULL, it won’t throw an exception.

Whereas, “.ToString()” does not handle NULL values and it will throw a NULL reference exception.

So as a good coding practice using “Convert.ToString()” is always safe.

Difference between Convert.ToString() and ToString() with example

Let’s see this with the help of an example:

For more details, you can visit MSDN links – Convert.ToString() and .ToString()

Difference between Convert.ToString() and ToString() Video

What’s new in C# 8.0?

Expected New Features In C# 8.0

DotNetCrunch

DotNetCrunch is a popular blog for latest Microsoft® technologies which is aimed for beginners and intermediate level professionals.

bayan escort escort bayan