why do we prefer ? to ?? operator in c#?

前端 未结 7 1944
别那么骄傲
别那么骄傲 2020-12-13 09:05

I recently found that we can use ?? operator to check nulls. Please check the below code samples:

   var res = data ?? new data();

This is

7条回答
  •  自闭症患者
    2020-12-13 09:33

    I think it's just a habit from other languages. AFAIK, ?? operator is not used in any other language.

提交回复
热议问题