Re: stringOperand + null = ?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 27 Apr 2007 07:37:12 +0100
Mark Chambers <no_spam@xxxxxxxxxxx> wrote:
Hi there,
In the expression A + B where A is a string and B isn't, I know that
"B.ToString()" will be called and the results concatenated. If B is null
however does the standard guarantee that "String.Empty" will be used
instead. Thanks.
Yup, the spec says:
<quote>
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.
</quote>
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: stringOperand + null = ?
- From: Mark Chambers
- Re: stringOperand + null = ?
- References:
- stringOperand + null = ?
- From: Mark Chambers
- stringOperand + null = ?
- Prev by Date: Re: random number generator help
- Next by Date: Re: Oddity with 'protected internal' and derivation
- Previous by thread: Re: stringOperand + null = ?
- Next by thread: Re: stringOperand + null = ?
- Index(es):
Relevant Pages
|