gpt4 book ai didi

.net - .NET字符串的内部格式是什么?

转载 作者:行者123 更新时间:2023-12-04 09:08:49 26 4
gpt4 key购买 nike

我在C#.NET中编写了一些漂亮的字符串操作密集型代码,并对我记得不久前记得的一些Joel Spolsky文章感到好奇:

http://www.joelonsoftware.com/articles/fog0000000319.html
http://www.joelonsoftware.com/articles/Unicode.html

那么,.NET如何做到呢?每个字符两个字节?有些Unicode chars ^ H ^ H ^ H ^ H ^ H代码点需要的更多。长度如何编码?

最佳答案

在Jon Skeet出现之前,这里是指向他在C#中的excellent blog on strings的链接。

In the current implementation at least, strings take up 20+(n/2)*4 bytes (rounding the value of n/2 down), where n is the number of characters in the string. The string type is unusual in that the size of the object itself varies

关于.net - .NET字符串的内部格式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1018915/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com