public boolean isValid() {if (bytes == null) {throw new IllegalStateException("bytes is null");}if (length < 0) {throw new IllegalStateException("length is negative: " + length);}if (length > bytes.length) {throw new IllegalStateException("length is out of bounds: " + length + ",bytes.length=" + bytes.length);}if (offset < 0) {throw new IllegalStateException("offset is negative: " + offset);}if (offset > bytes.length) {throw new IllegalStateException("offset out of bounds: " + offset + ",bytes.length=" + bytes.length);}if (offset + length < 0) {throw new IllegalStateException("offset+length is negative: offset=" + offset + ",length=" + length);}if (offset + length > bytes.length) {throw new IllegalStateException("offset+length out of bounds: offset=" + offset + ",length=" + length + ",bytes.length=" + bytes.length);}return true;}
public bool IsValid(){if (Bytes == null){throw new InvalidOperationException("bytes is null");}if (Length < 0){throw new InvalidOperationException("length is negative: " + Length);}if (Length > Bytes.Length){throw new InvalidOperationException("length is out of bounds: " + Length + ",bytes.length=" + Bytes.Length);}if (Offset < 0){throw new InvalidOperationException("offset is negative: " + Offset);}if (Offset > Bytes.Length){throw new InvalidOperationException("offset out of bounds: " + Offset + ",bytes.length=" + Bytes.Length);}if (Offset + Length < 0){throw new InvalidOperationException("offset+length is negative: offset=" + Offset + ",length=" + Length);}if (Offset + Length > Bytes.Length){throw new InvalidOperationException("offset+length out of bounds: offset=" + Offset + ",length=" + Length + ",bytes.length=" + Bytes.Length);}return true;}