static string NullToString( object Value )
{

    // Value.ToString() allows for Value being DBNull, but will also convert int, double, etc.
    return Value == null ? "" : Value.ToString();

    // If this is not what you want then this form may suit you better, handles 'Null' and DBNull otherwise tries a straight cast
    // which will throw if Value isn't actually a string object.
    //return Value == null || Value == DBNull.Value ? "" : (string)Value;


}
Answer from Gareth Wilson on Stack Overflow
Discussions

c# - How to convert nullable int to string - Stack Overflow
I need to convert the nullable int to string int? a = null; string str = a.ToString(); How can I perform this action without an exception? I need to get the string as "Null". Please guid... More on stackoverflow.com
🌐 stackoverflow.com
Convert null.String to string
There might be a super simple answer to this, but as a newbie at Go, I'm having an issue. I'm fetching some data from MSSQL and have set up some struct properties as null.String since the D... More on github.com
🌐 github.com
1
March 5, 2018
Use "+ string.Empty" or "?.ToString() ?? string.Empty" for a nullable object
string s = abc + string.Empty; That just looks like a weird line to have in code, without the context that it's handling the case that your string is null. I would personally go with something that looks more like an explicit null test; clarity of why the code exists is more important, in my opinion. That's without even thinking about the performance implications; I would expect a null check to be cheaper than string concatenation, even with an empty string. More on reddit.com
🌐 r/csharp
122
58
July 10, 2025
c# - Why does Convert.ToString(null) return a different value if you cast null? - Stack Overflow
The C# compiler essentially tries to pick the most specific overload which will work with the input. A null value is convertible to any reference type. In this case string is more specific than object and hence it will be picked as the winner. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.nullable-1.tostring
Nullable<T>.ToString Method (System) | Microsoft Learn
Class Sample Public Shared Sub Main() Dim nullableDate As Nullable(Of DateTime) ' Display the current date and time. nullableDate = DateTime.Now Display("1)", nullableDate) ' Assign null (Nothing in Visual Basic) to nullableDate, then ' display its value. nullableDate = Nothing Display("2)", nullableDate) End Sub ' Display the text representation of a nullable DateTime. Public Shared Sub Display(ByVal title As String, _ ByVal dspDT As Nullable(Of DateTime)) Dim msg As String = dspDT.ToString() Console.Write("{0} ", title) If String.IsNullOrEmpty(msg) Then Console.WriteLine("The nullable DateTime has no defined value.") Else Console.WriteLine("The current date and time is {0}.", msg) End If End Sub End Class 'This code example produces the following results: ' '1) The current date and time is 4/19/2005 8:28:14 PM.
🌐
TutorialsPoint
tutorialspoint.com › how-null-is-converted-to-string-in-javascript
How null is converted to String in JavaScript?
August 11, 2022 - The String() in JavaScript is used to convert a value to a String. To convert the null into a String just pass the null into this method.
🌐
TutorialsPoint
tutorialspoint.com › article › javascript-convert-array-with-null-value-to-string
JavaScript - convert array with null value to string
March 15, 2026 - The filter() method iterates through the array and removes elements that are null, undefined, or empty strings. The remaining elements are joined into a single string using join() method. Below is an example to convert an array with a null value to a string using filter() and join() methods ?
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › communitytoolkit › maui › converters › is-string-null-or-empty-converter
IsStringNullOrEmptyConverter - .NET MAUI Community Toolkit - Community Toolkits for .NET | Microsoft Learn
February 28, 2023 - The Convert method returns true when the binding value is null or string.Empty. The ConvertBack method is not supported. For the opposite behavior see the IsStringNotNullOrEmptyConverter.
🌐
C# Corner
c-sharpcorner.com › blogs › uses-of-tostring-and-converttostring-in-c-sharp
Uses Of Tostring() And Convert.Tostring() In C#
May 30, 2019 - string myName = null; ----------->Just assume they didn't give any input · Console.WriteLine(".ToString() : " + myName.ToString()); Console.WriteLine("Convert.ToString() :" + Convert.ToString(myName));
Find elsewhere
🌐
Pine
pineco.de › snippets › casting-null-values-string
Casting Null Values to String - Pine
July 5, 2021 - // Cast null to string // Then you can perform any "string" action (value || '').toString(); // Chain the methods after this
🌐
Salesforce
trailhead.salesforce.com › trailblazer-community › feed › 0D54V00007T3zXlSAJ
Convert NULL to Empty String - Trailhead - Salesforce
February 28, 2020 - Skip to main content · 2026 Agentblazer Status is coming soon! Get a head start by completing the current trails. See what's next
🌐
GitHub
github.com › guregu › null › issues › 28
Convert null.String to string · Issue #28 · guregu/null
March 5, 2018 - Before json encoding the structs, I need to manipulate them a bit and need to do some simple if statements, like: if row.x == "y" { //do stuff } but since row.x has the type null.String, that comparison fails with:
Author: guregu
🌐
Reddit
reddit.com › r/csharp › use "+ string.empty" or "?.tostring() ?? string.empty" for a nullable object
r/csharp on Reddit: Use "+ string.Empty" or "?.ToString() ?? string.Empty" for a nullable object
July 10, 2025 -

The Title basically says it all. If an object is not null, calling ".ToString()" is generally considered better than "+ string.Empty", but what about if the object could be null and you want a default empty string.

To me, saying this

void Stuff(MyObject? abc)
{
  ...
  string s = abc?.ToString() ?? string.Empty;
  ...
}

is much more complex than

void Stuff(MyObject? abc)
{
  ...
  string s = abc + string.Empty;
}

The 2nd form seems to be better than the 1st, especially if you have a lot of them.

Thoughts?

----

On a side note, something I found out was if I do this:

string s = myNullableString + "";

is the same thing as this

string s = myNullableString ?? "";

Which makes another branch condition. I'm all for unit testing correctly, but defaulting to empty string instead of null shouldn't really add another test.

using string.Empty instead of "" is the same as this:

string s = string.Concat(text, string.Empty);

So even though it's potentially a little more, I feel it's better as there isn't an extra branch test.

EDIT: the top code is an over simplification. We have a lot of data mapping that we need to do and a lot of it is nullable stuff going to non-nullable stuff, and there can be dozens (or a lot more) of fields to populate.

There could be multiple nullable object types that need to be converted to strings, and having this seems like a lot of extra code:

Mydata d = new()
{
  nonNullableField = x.oneField?.ToString() ?? string.Empty,
  anotherNonNullableField = x.anotherField?.ToString() ?? string.Empty,
  moreOfThesame = x.aCompletelyDifferentField?.ToString() ?? string.Empty,
  ...
}

vs

Mydata d = new()
{
  nonNullableField= x.oneField + string.Empty, // or + ""
  anotherNonNullableField= x.anotherField + string.Empty,
  moreOfThesame = x.aCompletelyDifferentField + string.Empty,
  ...
}

The issue we have is that we can't refactor a lot of the data types because they are old and have been used since the Precambrian era, so refactoring would be extremely difficult. When there are 20-30 lines that have very similar things, seeing the extra question marks, et al, seems like it's a lot more complex than simply adding a string.

🌐
Qlik Community
community.qlik.com › t5 › QlikView-App-Dev › Convert-Null-Values-into-String-or-Int › td-p › 1000130
Solved: Convert Null Values into String or Int - Qlik Community - 1000130
January 4, 2016 - My solution for this problem was to create a calculated dimension that changes the values (transforms what is Null into a string for example and the non-Nulls into nulls) and then click Suppress When Value is Null.
Top answer
1 of 2
150

There are 2 overloads of ToString that come into play here

Convert.ToString(object o);
Convert.ToString(string s);

The C# compiler essentially tries to pick the most specific overload which will work with the input. A null value is convertible to any reference type. In this case string is more specific than object and hence it will be picked as the winner.

In the null as object you've solidified the type of the expression as object. This means it's no longer compatible with the string overload and the compiler picks the object overload as it's the only compatible one remaining.

The really hairy details of how this tie breaking works is covered in section 7.4.3 of the C# language spec.

2 of 2
66

Following on from JaredPar's excellent overload resolution answer - the question remains "why does Convert.ToString(string) return null, but Convert.ToString(object) return string.Empty"?

And the answer to that is...because the docs say so:

Convert.ToString(string) returns "the specified string instance; no actual conversion is performed."

Convert.ToString(object) returns "the string representation of value, or String.Empty if value is null."

EDIT: As to whether this is a "bug in the spec", "very bad API design", "why was it specified like this", etc. - I'll take a shot at some rationale for why I don't see it as big deal.

  1. System.Convert has methods for converting every base type to itself. This is strange - since no conversion is needed or possible, so the methods end up just returning the parameter. Convert.ToString(string) behaves the same. I presume these are here for code generation scenarios.
  2. Convert.ToString(object) has 3 choices when passed null. Throw, return null, or return string.Empty. Throwing would be bad - doubly so with the assumption these are used for generated code. Returning null requires your caller do a null check - again, not a great choice in generated code. Returning string.Empty seems a reasonable choice. The rest of System.Convert deals with value types - which have a default value.
  3. It's debatable whether returning null is more "correct", but string.Empty is definitely more usable. Changing Convert.ToString(string) means breaking the "no actual conversion" rule. Since System.Convert is a static utility class, each method can be logically treated as its own. There's very few real world scenarios where this behavior should be "surprising", so let usability win over (possible) correctness.
🌐
Dotnetfunda
dotnetfunda.com › codes › show › 8143 › 3-ways-to-convert-null-values-to-empty-string-using-csharp
3 ways to convert Null values to Empty string using C# - DotNetFunda.com
March 11, 2017 - [CODE]string sampleString = null; var result1 = sampleString ?? string.Empty; var result2 = string.Concat(sampleString); var result3 = String.IsNullOrEmpt
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › communitytoolkit › maui › converters › is-string-null-or-whitespace-converter
IsStringNullOrWhiteSpaceConverter - .NET MAUI Community Toolkit - Community Toolkits for .NET | Microsoft Learn
February 28, 2023 - The Convert method returns true when the binding value is null, string.Empty or contains whitespace characters only. The ConvertBack method is not supported. For the opposite behavior see the IsStringNotNullOrWhiteSpaceConverter.