Maximum possible size of string in .net

Posted by Saranram under C# on 9/23/2011 | Points: 10 | Views : 1337 | Status : [Member] | Replies : 2
Hi,

What is Maximum possible size stored in string in .net?

Saran


Responses

Posted by: Gausi on: 9/23/2011 [Member] Starter | Points: 25

Up
0
Down
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.

This is one of those situations where "If you have to ask, you're probably doing something wrong."


Regards,

Gaurav Singh
(gausi)

Saranram, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranram on: 9/23/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Gausi,

Thanks for your valuable information. My system got hanged while assigning values into string variable from file which had huge data (file size is around 3GB). Thats why i raised that question.

Saran

Saranram, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response