In the following code below, why do the two string.Format
calls not behave the same way? In the first one, no exception is thrown, but in the second one an Ar
In case you use an interpolated string ($"", another way to format), the null is ignored, skipped. So
string nullString = null;
Console.WriteLine($"This is a '{nullString}' in a string");
will produce: "This is a '' in a string". Of course you can use the null coalescing operator in case of null to produce the output needed:
string nullString = null;
Console.WriteLine($"This is a '{nullString ?? "nothing"}' in a string");