国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

?? 運算符(C# 參考)

2019-11-17 03:00:54
字體:
來源:轉載
供稿:網友

?? 運算符(C# 參考)

??  運算符稱為 null 合并運算符,用于定義可以為 null 值的類型和引用類型的默認值。 如果此運算符的左操作數不為 null,則此運算符將返回左操作數;否則返回右操作數。

class NullCoalesce{    static int? GetNullableInt()    {        return null;    }    static string GetStringValue()    {        return null;    }    static void Main()    {        // ?? Operator example.        int? x = null;        // y = x, unless x is null, in which case y = -1.        int y = x ?? -1;        // Assign i to return value of method, unless        // return value is null, in which case assign        // default value of int to i.        int i = GetNullableInt() ?? default(int);        string s = GetStringValue();        // ?? also works with reference types.         // Display contents of s, unless s is null,         // in which case display "Unspecified".        Console.WriteLine(s ?? "Unspecified");    }}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 公主岭市| 图们市| 关岭| 乌鲁木齐县| 香格里拉县| 酒泉市| 樟树市| 石家庄市| 太保市| 弥渡县| 云南省| 保德县| 山东| 论坛| 谷城县| 广平县| 江源县| 扬州市| 法库县| 弥勒县| 海伦市| 崇明县| 山阳县| 丽江市| 福鼎市| 江孜县| 乌拉特前旗| 双桥区| 错那县| 颍上县| 潮州市| 壤塘县| 策勒县| 长宁区| 吉林省| 华阴市| 东城区| 永康市| 苍梧县| 临汾市| 嵊泗县|