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
🌐
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.
Discussions

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
java - Convert null object to String - Stack Overflow
I have written an android program to load values to table-row from web service. But value comes null so I need to convert it into a string. Can someone tell me the method to do it? try{ ... More on stackoverflow.com
🌐 stackoverflow.com
c# - How to do ToString for a possibly null object? - Stack Overflow
If you consider the second to be ... the null check. ... Per this answer Convert.ToString() does exactly the first thing you wrote underneath. ... Save this answer. ... Show activity on this post. ... Unfortunately, as has been pointed out you'll often need a cast on either side to make this work with non String or Object ... More on stackoverflow.com
🌐 stackoverflow.com
C#, how can someone create a null string?
The default value for any reference type is null. Even if they just press enter it still would just be an empty string. I don't see how someone could pass the program null as a value. Console.ReadLine() isn't the only way you can populate a string variable. There are plenty of use cases for null strings, its just that reading from the console isn't necessarily one of them. More on reddit.com
🌐 r/learnprogramming
12
1
May 20, 2023
🌐
TutorialsPoint
tutorialspoint.com › article › javascript-convert-array-with-null-value-to-string
JavaScript - convert array with null value to string
March 15, 2026 - If the value is falsy (null, undefined, or ""), it is replaced with an empty string "". Valid values are concatenated to form the final string.
🌐
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.
🌐
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.

🌐
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
Find elsewhere
🌐
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());
🌐
EDUCBA
educba.com › home › software development › software development tutorials › c# tutorial › c# nullable string
C# Nullable String | How to work with Nullable type with Examples?
May 20, 2023 - Apart from this, we can use Nullable.HasValue to check whether the object has been assigned a value or not. If the object has been assigned a value, it will return true if the object does not contain any value. We cannot use the nullable type with ‘var,’ and we cannot have the nested nullable type; it will give us a compile-time error. Now, let us talk about the null string in C#. We can directly assign null to a string in C# and assign a string with ‘string.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Stack Overflow
stackoverflow.com › questions › 4793601 › tostring-on-null-string
c# - ToString on null string - Stack Overflow
Updated - the exception I can understand, the puzzling bit (to me) is why the first part doesn't show an exception. This isn't anything to do with the Messagebox, as illustrated below. ... string s = null, msg; msg = "Message is " + s; //no error msg = "Message is " + s.ToString(); //error
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1635612 › assign-null-value-to-a-string-format
Assign 'null' value to a string.Format - Microsoft Q&A
March 28, 2024 - Instead of obj1.ATAVOYAGEREPORT, try to specify obj1.ATAVOYAGEREPORT?.ToString( ) ?? "null". If it is a string, then use obj1.ATAVOYAGEREPORT ??
🌐
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
🌐
C# Tutorial
csharp.net-informations.com › string › string-null-cs.htm
How to C# String Null
Instead, initialize it to the constant string.Empty ... An empty string is an instance of a System.String object that contains zero characters. You can call methods on empty strings because they are valid System.String objects. ... A null string does not refer to an instance of a System.String object and any attempt to call a method on a null string results in a NullReferenceException.
🌐
CodeGym
codegym.cc › java blog › strings in java › java: check if string is null, empty or blank
Java: Check if String is Null, Empty or Blank
October 11, 2023 - The String = Is the String null? false Is the String empty? true The String = Lubaina Khan · “A “blank” String in Java is equal to a String with one or multiple spaces.” As mentioned before, a “blank” String is different from a scenario where a String is null or empty.
Top answer
1 of 4
41

After reviewing my previous answer, it seems a complete overhaul of my previous answer is necessary. I was way over complicating it, as the short answer is that these are standards-specified special cases.

The specification for String() (String used as a function):

15.5.1.1 String ( [ value ] )

Returns a String value (not a String object) computed by ToString(value). If value is not supplied, the empty String "" is returned.

The ToString function (that exists internally, not in userland) is defined as follows (9.8):

"The abstract operation ToString converts its argument to a value of type String according to Table 13"

Argument Type | Result
Null | "null"
Undefined | "undefined"

This means that String(null) and String(undefined) go into this special table of types and just return the string values valued "null" and "undefined".

A user-land pseudo-implementation looks something like this:

function MyString(val) {
    if (arguments.length === 0) {
        return "";
    } else if (typeof val === "undefined") {
        return "undefined";
    } else if (val === null) {
        return "null";
    } else if (typeof val === "boolean") {
        return val ? "true" : "false";
    } else if (typeof val === "number") {
        // super complex rules
    } else if (typeof val === "string") {
        return val;
    } else {
        // return MyString(ToPrimitive(val, prefer string))
    }
}

(Note that this example ignores the constructor case (new MyString()) and that it uses user-land concepts rather than engine-land.)


I got a bit carried away and found an example implementation (V8 to be specific):

string.js:

// Set the String function and constructor.
%SetCode($String, function(x) {
  var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x);
  if (%_IsConstructCall()) {
    %_SetValueOf(this, value);
  } else {
    return value;
  }
});

macros.py:

macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString(arg));

runtime.js:

function NonStringToString(x) {
  if (IS_NUMBER(x)) return %_NumberToString(x);
  if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
  if (IS_UNDEFINED(x)) return 'undefined';
  return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
}

The NonStringToString (which is essentially what is of interest), is luckily defined in psuedo-JS-land. As you can see, there is indeed a special case for null/true/false/undefined.

2 of 4
2

There is probably just some extra checks and handling for special cases like null and undefined.

MDN says:

It's possible to use String as a "safer" toString alternative, as although it still normally calls the underlying toString, it also works for null and undefined.

🌐
DZone
dzone.com › data engineering › data › string.valueof(object) vs. objects.tostring(object)
String.valueOf(Object) Vs. Objects.toString(Object) - DZone
August 28, 2018 - Although I typically use String.valueOf(Object) instead of Objects.toString(Object) by default when I want the string "null" returned if the passed-in object is null, the alternate overloaded method Objects.toString(Object, String) has the advantage ...
🌐
Quora
quora.com › What-the-heck-does-null-string-mean-In-laymans-terms-I-looked-up-the-definition-and-I-still-dont-get-it-Can-you-please-put-it-simple-terms
What the heck does null string mean? In layman's terms, I looked up the definition and I still don't get it. Can you please put it simple terms? - Quora
Answer (1 of 5): Technically, a string is a list of symbols, themselves called “characters”. The “null string” is just what you call it when the list is empty. It’s also called the “empty string”, for obvious reasons. The reason for its existence has to do with the algebra of strings.