我在考试中看到过这个代码示例问题,它完美地工作。什么是“int?”在C#类型中
namespace Trials_1
{
class Program
{
static void Main(string[] args)
{
int? a = 9;
Console.Write("{0}", a);
}
}
}
但是,下面的代码会引发错误CS0266。
namespace Trials_1
{
class Program
{
static void Main(string[] args)
{
int? a = 9;
int b = a;
Console.Write("{0},{1}", a, b);
}
}
}
有人可以详细解释我吗?
的可能的复制[如何转换C#可空int到int](http://stackoverflow.com/questions/5995317/how-to-convert-c-sharp-nullable-int-to-int) – MickyD