the internals of System.String

前端 未结 4 573
遇见更好的自我
遇见更好的自我 2021-02-13 08:59

I used reflection to look at the internal fields of System.String and I found three fields:

m_arrayLength

m_stringLength

m_firstChar

I don\'t

4条回答
  •  离开以前
    2021-02-13 09:46

    Much of the implementation of System.String is in native code (C/C++) and not in managed code (C#). If you take a look at the decompiled code you'll see that most of the "interesting" or "core" methods are decorated with this attribute:

    [MethodImpl(MethodImplOptions.InternalCall)]
    

    Only some of the helper/convenience APIs are implemented in C#.

    So where are the characters for the string stored? It's top secret! Deep down inside the CLR's core native code implementation.

提交回复
热议问题