在C#中我们可以这样做:
Int32 i = new Int32();
Run Code Online (Sandbox Code Playgroud)
但是,以下内容将返回null:
typeof(Int32).GetConstructor(new Type[0])
Run Code Online (Sandbox Code Playgroud)
为什么是这样?
我检查了文档,没有找到解决这个问题的原因.
我的结果可以在下面的代码中说明:
using System;
public class Program
{
public static void Main()
{
Int32 i = new Int32();
Console.WriteLine(i);
Console.WriteLine(typeof(Int32).GetConstructor(new Type[0]) == null);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是:
0
真正