在 Java 中,一个空字符串是 40 个字节。在 Python 中它是 20 个字节。 C# 中的空字符串对象有多大?我无法执行 sizeof
,而且我不知道如何找出答案。谢谢。
最佳答案
16 bytes of memory + 2 bytes per character allocated + 2 bytes for the final null character.
请注意,这是关于 .Net 1.1 的。
.Net 4.0 中删除了 m_ArrayLength
字段(您可以在引用源中看到这一点)
关于c# - C#中的空字符串大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5690922/