int? a; //a = null; // 此时b为3 a = 6; // 此时b为6 int b = a ?? 3; Console.WriteLine(b);
意思是:如果??左边为null,则取右边的值,如果左边不为null,就取左边的值