System.IO.MemoryStream.EnsureCapacity C# (CSharp) Méthode

EnsureCapacity() private méthode

private EnsureCapacity ( int value ) : bool
value int
Résultat bool
        private bool EnsureCapacity(int value)
        {
            // Check for overflow
            if (value < 0)
            {
                throw new IOException(SR.IO_IO_StreamTooLong);
            }
            if (value > _capacity)
            {
                int newCapacity = value;
                if (newCapacity < 256)
                {
                    newCapacity = 256;
                }
                if (newCapacity < _capacity * 2)
                {
                    newCapacity = _capacity * 2;
                }

                Capacity = newCapacity;
                return true;
            }
            return false;
        }