public void Write (long offset, char [] buffer, int offsetInBuffer, int count) { if (count > this.MaxLength || ((count + offset) > this.MaxLength) || count > buffer.Length || count < 0 || ((offsetInBuffer + count) > buffer.Length)) throw new SqlTypeException ("The buffer is insufficient. Read or write operation failed."); if (offset < 0 || offset > MaxLength) throw new ArgumentOutOfRangeException ("offset"); if (offsetInBuffer < 0 || offsetInBuffer > buffer.Length || offsetInBuffer > this.Length) throw new ArgumentOutOfRangeException ("offsetInBuffer"); if (this.IsNull && offsetInBuffer != 0) throw new ArgumentOutOfRangeException ("offsetInBuffer"); if (buffer == null) throw new ArgumentNullException ("buffer"); long actualCount = count; if (count + offset > this.MaxLength) actualCount = this.MaxLength - offset; if (actualCount + offset > this.Length) SetLength (actualCount); Array.Copy (buffer, offsetInBuffer, this.buffer, offset, actualCount); }