在.net-core中Int32的真正实现在哪里

时间:2016-07-03 03:03:10

标签: c# .net-core

我已经从github克隆了dotnet核心的代码,想要读取有关System.Int32的src代码,但我发现Int32的代码真的很奇怪。

public partial struct Int32 : System.IComparable, System.IComparable<int>, System.IConvertible, System.IEquatable<int>, System.IFormattable
{
    public const int MaxValue = 2147483647;
    public const int MinValue = -2147483648;
    public int CompareTo(int value) { return default(int); }
    public bool Equals(int obj) { return default(bool); }
    public override bool Equals(object obj) { return default(bool); }
    public override int GetHashCode() { return default(int); }
    public static int Parse(string s) { return default(int); }
    public static int Parse(string s, System.Globalization.NumberStyles style) { return default(int); }
    public static int Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider) { return default(int); }
    public static int Parse(string s, System.IFormatProvider provider) { return default(int); }
    int System.IComparable.CompareTo(object value) { return default(int); }
    System.TypeCode System.IConvertible.GetTypeCode() { return default(System.TypeCode); }
    bool System.IConvertible.ToBoolean(System.IFormatProvider provider) { return default(bool); }
    byte System.IConvertible.ToByte(System.IFormatProvider provider) { return default(byte); }
    char System.IConvertible.ToChar(System.IFormatProvider provider) { return default(char); }
    System.DateTime System.IConvertible.ToDateTime(System.IFormatProvider provider) { return default(System.DateTime); }
    decimal System.IConvertible.ToDecimal(System.IFormatProvider provider) { return default(decimal); }
    double System.IConvertible.ToDouble(System.IFormatProvider provider) { return default(double); }
    short System.IConvertible.ToInt16(System.IFormatProvider provider) { return default(short); }
    int System.IConvertible.ToInt32(System.IFormatProvider provider) { return default(int); }
    long System.IConvertible.ToInt64(System.IFormatProvider provider) { return default(long); }
    sbyte System.IConvertible.ToSByte(System.IFormatProvider provider) { return default(sbyte); }
    float System.IConvertible.ToSingle(System.IFormatProvider provider) { return default(float); }
    object System.IConvertible.ToType(System.Type type, System.IFormatProvider provider) { return default(object); }
    ushort System.IConvertible.ToUInt16(System.IFormatProvider provider) { return default(ushort); }
    uint System.IConvertible.ToUInt32(System.IFormatProvider provider) { return default(uint); }
    ulong System.IConvertible.ToUInt64(System.IFormatProvider provider) { return default(ulong); }
    public override string ToString() { return default(string); }
    public string ToString(System.IFormatProvider provider) { return default(string); }
    public string ToString(string format) { return default(string); }
    public string ToString(string format, System.IFormatProvider provider) { return default(string); }
    public static bool TryParse(string s, System.Globalization.NumberStyles style, System.IFormatProvider provider, out int result) { result = default(int); return default(bool); }
    public static bool TryParse(string s, out int result) { result = default(int); return default(bool); }
}

Int32的所有方法只返回默认值,那么在哪里可以找到System.Int32的真实实现?

1 个答案:

答案 0 :(得分:5)

.net中的几乎每种数据类型都是 CLR 的一部分,因此您可以在coreclr项目中找到数据类型的实现。

CoreCLR

在项目中,我在此链接中找到了System.Int32的实现。 System.Int32 source code

我想,这就是你想要的。