Difference Between Convert.ToString & ToString methods in C#

preview_player
Показать описание
Difference Between Convert.ToString & ToString methods in C# | DotNetCrunch

In this video, we will understand the difference between static Convert.ToString() method and instance ToString() method

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.

Difference between Convert.ToString() and .ToString methods in C#

This is one of those famous C# and .NET interview question which is asked frequently to freshers or intermediate level programmers. To answer precisely and shortly Convert.ToString handles nulls while simple .ToString() doesn't.

About DotnetCrunch
-------------------------------------------------------------------
DotNetCrunch is a programming/technology blog originated at India. Stating, India doesn’t limit us to specific territory, we cover global audience and we make sure that our readers will keep getting regular updates along with helpful Coding/Tech how to tips.

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

Connect with DotNetCrunch:
-----------------------------------------------------------------------
You can connect with DotNetCrunch on various social networking sites. Connecting with us on different social networking site, will bring our interaction one way closer and you will keep receiving our updates for free.

#DotNetCrunch #CSharp #ToStringAndConvertToString

Happy Coding! Stay Geek!

TAGS:
c# convert string null to empty
c# tostring object reference not set to an instance of an object
convert null to empty string c#
c# tostring null value
c# tostring null object
c# tostring null reference exception
c# tostring null empty
.net nullable tostring
.net tostring null
Рекомендации по теме
welcome to shbcf.ru