-1

i was wondering what is the maximum number of characters that can be stored in a string variable In C#

  • @HansPassant on 32bit applications I assume? or does 2 GB also apply to 64Bit applications? – Rand Random Aug 18 '22 at 16:56
  • It's worth noting that you don't "store characters in a string". A string consists of characters that are there from the point the object is initialized. Strings are immutable and shouldn't be thought of as a storage medium. Your question is better phrased as "what is the maximum length of a string?" – Flydog57 Aug 18 '22 at 18:10

1 Answers1

2

The maximum size of a String object in memory is 2-GB, or about 1 billion characters.

https://learn.microsoft.com/en-us/dotnet/api/system.string?redirectedfrom=MSDN&view=net-6.0

Voidsay
  • 1,462
  • 2
  • 3
  • 15