Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

Maximum length of a string

What is the maximum length of a string.  I am trying to store a document in a variable and my plan was to use a string, but I don't know what the maximum length is.  If there is one, is there a better way to store a 500 word document in a variable?

0
johnywhite
Asked:
johnywhite
3 Solutions
 
Ravi SinghSenior Software EngineerCommented:
Maximum length of string is 2147483648 unicode characters.

See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vadatString.asp
0
 
nickhoggardCommented:
Hi,

I can't say that I have ever come across a problem with a string getting too long, but I did find the following article that indicates that the max length is something approaching UInt32.Max.
http://www.codeproject.com/dotnet/strings.asp

If you document is only 500 words then it should be well within the realms of being stored within a String variable.

Cheers

Nick
0
 
Jeff CertainCommented:
You may find that (depending on version) your string limit is actually closer to 32K. At least, this is the maximum you can display in a text box... so I'd take that as the practical limit if UI is involved.
0
 
johnywhiteAuthor Commented:
Thanks, that is what I was looking for.
0
 
Jeff CertainCommented:
Glad to help.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now