【发布时间】:2015-06-08 10:53:31
【问题描述】:
为什么Int32 在其source code 中使用int? Int32 在 C# 中不等于 int 吗?那么int的原始源代码是什么?我很困惑..
[Serializable]
[System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)]
[System.Runtime.InteropServices.ComVisible(true)]
#if GENERICS_WORK
public struct Int32 : IComparable, IFormattable, IConvertible
, IComparable<Int32>, IEquatable<Int32>
/// , IArithmetic<Int32>
#else
public struct Int32 : IComparable, IFormattable, IConvertible
#endif
{
internal int m_value; // Here????
public const int MaxValue = 0x7fffffff;
public const int MinValue = unchecked((int)0x80000000);
...
}
Boolean 和 bool 之间也存在同样的问题。
【问题讨论】:
-
Int32 是
struct。它包含用于操作 int 的方法和内容,int 是系统定义的数据类型。 -
那是
int的原始源代码。一些实际的内部工作是编译器和运行时的一部分,但只要有源代码,那就是源代码。 -
为什么你认为它不必使用int?
-
@TimSchmelter 绝对重复。很好的发现。 :)
标签: c# int32 reference-source