C# 中的 int
是什么?它是关键字,还是派生自 system.ValueTypes 的类?如果它是一个关键字那么下面几行如何编译
int i = new int(); // If int is not a class then how does it have a default constructor
Console.WriteLine(i.ToString()); // If int is not a class then how does it have member functions
如果 int
是一个类,那么为什么不需要总是用 new
初始化它?下面一行如何编译?
int i = 8;
最佳答案
int 是 CTS 类型 System.Int32
的别名 structure .
阅读 Eric Lippert 发布的 SO 答案 - How do ValueTypes derive from Object (ReferenceType) and still be ValueTypes?
关于c# - c#中的int是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11589354/