C# 2.0: Coalescing?

Published 02 August 07 06:46 PM | adrian

When I write:

profile.LastName != null ? profile.LastName : " "

Resharper recommended coalescing into:

profile.LastName ?? " "

What's this? Any help is appreciated.

Share this post: | | | |

Comments

# Jimmy Chandra said on August 3, 2007 02:04 PM:

if profile.LastName is null then it will return " " else it will return profile.LastName. Basically the same as your first statement. more compact than the firs version is all. profile.LastName = profile.LastName ?? " ";

# adrian said on August 3, 2007 02:53 PM:

Yes, I know what it does. Just wondering what's the name/the theory or documentation/anything else than what it does.

# SKIP. said on August 6, 2007 11:14 AM:

Berarti ?? menunjukkan LastName yang tidak initial harus di set dengan apa. Cool jg.