拿一个C#字符串多少钱。 [英] how much take a C# string.

查看:84
本文介绍了拿一个C#字符串多少钱。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我怀疑与我的asp.net应用程序有关。



C#string存储的数据大小。

请指定尺码。我的意思是KBs的字节。

请指定范围。

Hi,

I have doubt related to my asp.net application.

C# string how much size of data stored.
Please Specified in a size. I mean KBs of bytes.
Specify the range please.

推荐答案

字符串长度是一个int,所以它的大小是2,147,483,647 ......但我猜测你会在加载该字符串之前遇到其他问题,例如内存问题。大约最大字符串可能是2 gig,但真正的问题是从堆中获取足够的内存作为分配,这将限制一到一半的大小。



参考: http://social.msdn .microsoft.com /论坛/ vstudio / zh-CN / 51977e6b-aeef-47b5-92a9-0d00572856fd / maximum-string-size [ ^ ]
String length is an int so the its size is 2,147,483,647...but I would surmise you will hit other problems such as memory issues before loading up that string. Roughly the max string could be 2 gig, but the real issue is getting enough memory from the heap as an allocation, which would limit one to half that size.

Ref: http://social.msdn.microsoft.com/Forums/vstudio/en-US/51977e6b-aeef-47b5-92a9-0d00572856fd/maximum-string-size[^]


试试这个你会得到确切的答案。



Try this you will get the exact answer.

static void Eg3()
       {
           string str = "a";
           try
           {
               while (1 == 1)
               {
                   str = str + "a";
               }

           }
           catch (Exception ex)
           {
               Console.WriteLine(str.Length);

               throw ex;
           }
       }


这篇关于拿一个C#字符串多少钱。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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