Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string limit

Status
Not open for further replies.

cosmoh2o

Programmer
Jul 22, 2002
92
0
0
US
Quick question,
Does anyone know the max length of a string in .net with C#?

Thanks
 
In fact there is no limitation.
Secondly a String is immutable.
If you need string with huge size then use StringBuilder.

-obislavu-
 
obislavu - you're right - I'm so used to 32-bit systems where you'd have a 2gb limit. Since .NET is 64 bit aware, strings can essentially be as large as you have swap space available.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Hi,

Both the posts are right.

However, because the string cannot change size once it is allocated, it is better to use a System.Text.StringBuilder if you want to concatenate or play around with the string. Allocation of a StringBuilder object is dynamic and much more performant.

It has nothing to so with size though.
 
Thanks to everybody for the quick responses. I am relatively new to .NET and C# but am learning. I will be sure to use StringBuilder if I have to concantenate strings. Thanks again to everybody.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top