“StringPlusNull” (Solution)

Answer

1
False
Copied!

Explanation

A text fragment from C# Language Specification, the “7.8.4 Addition operator” section:
“String concatenation:
1
string operator +(string x, string y);
2
string operator +(string x, object y);
3
string operator +(object x, string y);
Copied!
These overloads of the binary + operator perform string concatenation. If an operand of string concatenation is null, an empty string is substituted. Otherwise, any non-string argument is converted to its string representation by invoking the virtual ToString method inherited from type object. If ToString returns null, an empty string is substituted.”
Thus:
1
((string)null + null + null) == ("" + null + null) ==
2
(("" + null) + null) == (("" + "") + null) == ("" + null) ==
3
("" + "") == ""
4
"" != null
Copied!

Links

Problem
Copy link