In c# , what does it mean '??'?

This question already has an answer here:

  • What do two question marks together mean in C#? 16 answers
  • ?? Null Coalescing Operator --> What does coalescing mean? 6 answers
  • Unique ways to use the Null Coalescing operator 15 answers

  • It is called a Null coalescing operator

    if the first part is null then use the next part, in your case if _command is null then it creates a new command else it would use _command only


    it's Null coalescing operator. It means if this has a value use it, if not use the next item.

    It's very useful for nullable types and objects.

    int? age = null; 
    
    var defaultAge = age ?? 21;
    //defaultAge is now 21
    

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


    Null Coalesce operator. Functions just like, "IsNull" in TSQL. If the left value is not null, use it. Otherwise, use the right value.

    链接地址: http://www.djcxy.com/p/53846.html

    上一篇: 在这种情况下合并操作员工作?

    下一篇: 在C#中,它是什么意思'??'?