Primitive types in .net

后端 未结 1 845
深忆病人
深忆病人 2021-02-19 07:28

In .net, AIUI int is just syntactic sugar for System.Int32, which is a struct.

csharp> typeof(System.Int32).IsPrimitive         


        
相关标签:
1条回答
  • 2021-02-19 07:33

    There is an excellent explanation in Dixin's blog article Understanding .NET Primitive Types.

    The answer can be found in the generated IL. His following question is actually the answer to your question:

    So what is the relationship among int32 (IL), int (C#) and System.Int32 (C#)?

    In the IL can be found that the int inside the struct is:

    .field assembly int32 m_value
    

    So that int32 actually exists outside .NET and is the actual representation of the .NET int in assembly.

    0 讨论(0)
提交回复
热议问题