System.Net.Sockets.SocketAsyncEventArgs.SetBufferInternal C# (CSharp) Method

SetBufferInternal() private method

private SetBufferInternal ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
return void
        private void SetBufferInternal(byte[] buffer, int offset, int count)
        {
            StartConfiguring();
            try
            {
                if (buffer == null)
                {
                    // Clear out existing buffer.
                    _buffer = null;
                    _offset = 0;
                    _count = 0;
                }
                else
                {
                    // Can't have both Buffer and BufferList.
                    if (_bufferList != null)
                    {
                        throw new ArgumentException(SR.Format(SR.net_ambiguousbuffers, "BufferList"));
                    }

                    // Offset and count can't be negative and the 
                    // combination must be in bounds of the array.
                    if (offset < 0 || offset > buffer.Length)
                    {
                        throw new ArgumentOutOfRangeException(nameof(offset));
                    }
                    if (count < 0 || count > (buffer.Length - offset))
                    {
                        throw new ArgumentOutOfRangeException(nameof(count));
                    }

                    _buffer = buffer;
                    _offset = offset;
                    _count = count;
                }

                // Pin new or unpin old buffer if necessary.
                SetupSingleBuffer();
            }
            finally
            {
                Complete();
            }
        }
SocketAsyncEventArgs