Possible Duplicate:
What do two question marks together mean in C#?
Hi, I was looking for some trainings of MVC 2 in C# and I found this sintax:
ViewData["something"] = something ?? true;
So, what is that ‘??’ means ?.
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 returns the first argument unless it is null, in which case it returns the second.
x ?? yis roughly equivalent to this (except that the first argument is only evaluated once):Or alternatively:
It is useful for providing a default value for when a value can be null:
COALESCE
When used in a LINQ to SQL query the
??operator can be translated to a call to COALESCE. For example this LINQ query:can result in this SQL query: