Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "??" mean?

Tags:

c#

I'm looking at the generated code by ASP.NET MVC 1.0, and was wondering; what do the double question marks mean?

// This constructor is not used by the MVC framework but is instead provided for ease
// of unit testing this type. See the comments at the end of this file for more
// information.
public AccountController(IFormsAuthentication formsAuth, IMembershipService service)
{
    FormsAuth = formsAuth ?? new FormsAuthenticationService();
    MembershipService = service ?? new AccountMembershipService();
}

Related:

?? Null Coalescing Operator —> What does coalescing mean?

like image 385
Brian Liang Avatar asked Apr 20 '09 21:04

Brian Liang


1 Answers

This is the null-coalescing operator. It will return the value on its left if that value is not null, else the value on the right (even if it is null). They are often chained together ending in a default value.

Check out this article for more

like image 183
JoshJordan Avatar answered Sep 22 '22 01:09

JoshJordan