C# equivalent of the IsNull() function in SQL Server

前端 未结 10 2107
太阳男子
太阳男子 2020-12-12 21:53

In SQL Server you can use the IsNull() function to check if a value is null, and if it is, return another value. Now I am wondering if there is anything similar

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 21:55

    It's called the null coalescing (??) operator:

    myNewValue = myValue ?? new MyValue();
    

提交回复
热议问题