示例#1
0
        /// <summary>
        /// Read the specified number of characters from the buffer, starting
        /// at the specified offset into the buffer and writing to the specified
        /// offset in the destination buffer.
        /// </summary>
        /// <param name="sourceIndex">The offset into the buffer at which
        /// to start reading.</param>
        /// <param name="buffer">The buffer to write the characters to.</param>
        /// <param name="destinationIndex">The index in the destination buffer
        /// at which to start writing.</param>
        /// <param name="count">The number of characters to read.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="buffer"/>
        /// is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when indicated
        /// range would require reading past the end of the the input buffer or
        /// writing past the end of the provided output buffer.</exception>
        public void ReadAt(int sourceIndex, char[] buffer, int destinationIndex, int count)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (sourceIndex + count > _buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(sourceIndex));
            }

            if (destinationIndex + count > buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(buffer));
            }

            _buffer.CopyTo(sourceIndex, buffer, destinationIndex, count);
        }