简单类型 / 可空类型

using System;

int? n1 = GetIntValue(false);
var exists1 = n1.HasValue;
//exists1 is True

int? n2 = GetIntValue(true);
var exists2= n2 != null;
//exists2 is False

Console.WriteLine("{0}{1}", exists1, exists2);

intGetIntValue(bool isNull) {
    return isNull ? null : 42;
}