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?

Who is Participating?

Improve company productivity with a Business Account.Sign Up

Jeff CertainConnect With a Mentor Commented:
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.
Ravi SinghConnect With a Mentor Senior Software EngineerCommented:
Maximum length of string is 2147483648 unicode characters.

nickhoggardConnect With a Mentor Commented:

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.

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


johnywhiteAuthor Commented:
Thanks, that is what I was looking for.
Jeff CertainCommented:
Glad to help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.