什么是.NET字符串的最大可能长度? [英] What is the maximum possible length of a .NET string?

查看:305
本文介绍了什么是.NET字符串的最大可能长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是可在.NET创建的最长字符串?该文档的字符串类没有提及这个问题,据我所看到的,因此,一个权威的答案,可能需要内部的一些知识。请问在64位系统上的最大变化?

What is the longest string that can be created in .NET? The docs for the String class are silent on this question as far as I can see, so an authoritative answer might require some knowledge of internals. Would the maximum change on a 64-bit system?

[这是要求多为好奇心比实际使用 - !我不打算创建使用巨大的字符串的所有code]

[This is asked more for curiosity than for practical use - I don't intend to create any code that uses gigantic strings!]

推荐答案

的理论极限可能是2,147,483,647,但实际限制是隔靴搔痒的。由于在.NET程序中没有单独的对象可能会超过2GB和字符串类型使用UNI code(2字节每个字符),你可以做的最好的是1,073,741,823,但你不可能永远能够分配一个32位的机器上。

The theoretical limit may be 2,147,483,647, but the practical limit is nowhere near that. Since no single object in a .Net program may be over 2GB and the string type uses unicode (2 bytes for each character), the best you could do is 1,073,741,823, but you're not likely to ever be able to allocate that on a 32-bit machine.

这是那些如果你要问,你是情形之一可能是做错了什么。

这篇关于什么是.NET字符串的最大可能长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆