Possible Duplicate:
What do two question marks together mean in C#?
I’m trying to understand what this statment does: what does “??” mean?
is this som type if if-statment?
string cookieKey = "SearchDisplayType" + key ?? "";
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s the Null Coalescing operator. It means that if the first part has value then that value is returned, otherwise it returns the second part.
E.g.:
Or some actual code:
What this example is doing is casting the customers as an
IList<Customer>. If this cast results in a null, it’ll call the LINQToListmethod on the customer IEnumerable.The comparable if statement would be this:
Which is a lot of code compared to doing it within a single line using the null-coalescing operator.