System.Data.SqlTypes.SqlBytes.SetLength C# (CSharp) Method

SetLength() public method

public SetLength ( long value ) : void
value long
return void
        public void SetLength(long value)
        {
            if (value < 0)
                throw new ArgumentOutOfRangeException(nameof(value));

            if (FStream())
            {
                _stream.SetLength(value);
            }
            else
            {
                // If there is a buffer, even the value of SqlBytes is Null,
                // still allow setting length to zero, which will make it not Null.
                // If the buffer is null, raise exception
                //
                if (null == _rgbBuf)
                    throw new SqlTypeException(SR.SqlMisc_NoBufferMessage);

                if (value > _rgbBuf.Length)
                    throw new ArgumentOutOfRangeException(nameof(value));

                else if (IsNull)
                    // At this point we know that value is small enough
                    // Go back in buffer mode
                    _state = SqlBytesCharsState.Buffer;

                _lCurLen = value;
            }

            AssertValid();
        }

Usage Example

Beispiel #1
0
        public override void SetLength(long value)
        {
            CheckIfStreamClosed("SetLength");

            m_sb.SetLength(value);
            if (m_lPosition > value)
            {
                m_lPosition = value;
            }
        }
All Usage Examples Of System.Data.SqlTypes.SqlBytes::SetLength