Regarding Primitive Data Types in C#
此msdn文章处理数据类型。
它说:
For each primitive data type in Java, the core class library provides
a wrapper class that represents it as a Java object. For example, the
Int32 class wraps the int data type, and the Double class wraps the
double data type.On the other hand, all primitive data types in C# are objects in the
System namespace. For each data type, a short name, or alias, is
provided. For instance, int is the short name for System.Int32 and
double is the short form of System.Double.
我运行mono代码来读取system.int32结构的实现。
我发现有几行话迫使我问这个问题:
1 2 3 4 5 | public const int MaxValue = 0x7fffffff; public const int MinValue = -2147483648; // This field is looked up by name in the runtime internal int m_value; |
我假设MS将以相同的方式实现这个结构。这和包装纸有什么不同吗?文件到底要传达什么?
如果要相信msdn,system.int32结构对我来说将是无休止的递归和极大的混乱。
Is this any different from a wrapper?
C语言中的原始类型没有包装类型,如Java中的包类型,而对于EDCOX1(0)的别名
C语言中的原始类型可以被装箱,就像在Java中一样,但是在C语言中,当它们被装箱时,它们被装箱到EDCOX1(3)中,而在Java中,它们被装箱到它们的包装类型。
What exactly is the documentation trying to convey?
这两种相似但不同的语言有区别。天真地一瞥,就会发现这些东西是一样的:
Java:EDCOX1〔0〕-> EDCOX1〔5〕
C:
但事实并非如此。在爪哇中,
If MSDN is to be believed System.Int32 struct would be endlessly recursive and greatly confusing for me at least.
所以,要非常清楚:
1 2 3 4 5 | public const int MaxValue = 0x7fffffff; public const int MinValue = -2147483648; // This field is looked up by name in the runtime internal int m_value; |
可重写为
1 2 3 4 5 | public const System.Int32 MaxValue = 0x7fffffff; public const System.Int32 MinValue = -2147483648; // This field is looked up by name in the runtime internal System.Int32 m_value; |
这根本没有改变它的含义,因为
回复:递归定义。公共语言基础结构(CLI)中内置了某些类型。我们被告知:
The CLI built-in types have corresponding value types defined in the Base Class Library. They shall be
referenced in signatures only using their special encodings (i.e., not using the general purpose valuetype
TypeReference syntax). Partition I specifies the built-in types.
也就是说,
如果您想了解.NET框架规范,可以从这里下载(我引用了