Asp.NET ??運算符

??表示當運算符左邊為空時,顯示右邊值,否則顯示其左邊值
如代碼所示:
        int c = 888;

        
//定義為空
        int? cc = null;

        
//下邊這樣定義為空報錯(因為這是實值型別,無法將 null 轉換成 'int')
        int cn = null;

        
//??當左邊為空時,顯示右邊,否則顯示左邊
        Response.Write(Convert.ToString(cc ?? c));

結果:888

int? cc = 6;
Response.Write(Convert.ToString(cc 
?? c));

結果:6

原文地址:https://www.cnblogs.com/scottckt/p/1123720.html