Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

?? operator

Status
Not open for further replies.

DarwinIT

Programmer
Apr 25, 2008
142
US
I found the following in code I inherited.


MainClass.Logger.LogEvent(this, new BCIDEventArgs(new BCIDEvent(BCIDDEventLevel.Info, Core.Instance.UserName, null, null, log.MessageText ?? string.Empty)
));

What is the function of ?? in log.MessageText ?? string.Empty ??

I don't find that listed in the operator section of Inside C#. Is this perhaps new to 2008?



 
Code:
string nullstring = null;
if(nullstring == null)
 return string.Empty;
return nullstring;
is the same as
Code:
string nullstring = null;
return nullstring ?? string.Empty;

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
So it would be comparable to the IsNull function in SQL Server isNull(@nullstring,'')

Thanks!!!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top