How long can a string be?
How long can a System.String be? I know that the Length() method returns a signed Int32, so it probably can't exceed 2^31 (2 billion something) characters.
Does anyone know if its length is further restricted to a smaller maximum?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Mike GoldRank #50 · 30.6K pointsPosted Jul 10, 2006, 7:49 PM EDT
public StringBuilder(int capacity) { this.m_currentThread = StringBuilder.InternalGetCurrentThread(); this.m_MaxCapacity = 0; this.m_StringValue = null; if (capacity < 0) { throw new ArgumentOutOfRangeException("capacity", string.Format(Environment.GetResourceString("ArgumentOutOfRange_MustBePositive"), "capacity")); } if (capacity == 0) { capacity = 0x10; } this.m_StringValue = string.GetStringForStringBuilder(string.Empty, capacity); this.m_MaxCapacity = 0x7fffffff; }