What do two question marks together mean in C#?

前端 未结 18 1328
借酒劲吻你
借酒劲吻你 2020-11-22 03:41

Ran across this line of code:

FormsAuth = formsAuth ?? new FormsAuthenticationWrapper();

What do the two question marks mean, is it some ki

18条回答
  •  春和景丽
    2020-11-22 04:33

    It's the null coalescing operator.

    http://msdn.microsoft.com/en-us/library/ms173224.aspx

    Yes, nearly impossible to search for unless you know what it's called! :-)

    EDIT: And this is a cool feature from another question. You can chain them.

    Hidden Features of C#?

提交回复
热议问题