Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.
Posted

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[^]
 
Share this answer
 
Comments
Mycroft Holmes 30-May-14 3:21am    
I thought it was a dumb question at first, of course it is defined by the memory you have use, then I started looking for the number and failed to find it in 5 minutes, about the limit of my attention span.
Naz_Firdouse 30-May-14 3:24am    
:)
Ajith K Gatty 30-May-14 3:41am    
Hey Naz, Nice answer for a good curious question.
Try this you will get the exact answer.

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

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

               throw ex;
           }
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900