/// <summary> /// Requires the range [offset, offset + count] to be a subset of [0, array.Count]. /// </summary> /// <exception cref="ArgumentNullException">String is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException">Offset or count are out of range.</exception> public static void RequiresArrayRange( string str, int offset, int count, string offsetName, string countName ) { Proclaim.NotEmpty( offsetName ); Proclaim.NotEmpty( countName ); Proclaim.NotNull( str ); if( count < 0 ) { throw new ArgumentOutOfRangeException( countName ); } if( offset < 0 || str.Length - offset < count ) { throw new ArgumentOutOfRangeException( offsetName ); } }
/// <summary> /// Requires the range [offset, offset + count] to be a subset of [0, array.Count]. /// </summary> /// <exception cref="ArgumentNullException">Array is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException">Offset or count are out of range.</exception> public static void RequiresArrayRange<T>( IList<T> array, int offset, int count, string offsetName, string countName ) { Proclaim.NotEmpty( offsetName ); Proclaim.NotEmpty( countName ); Proclaim.NotNull( array ); if( count < 0 ) { throw new ArgumentOutOfRangeException( countName ); } if( offset < 0 || array.Count - offset < count ) { throw new ArgumentOutOfRangeException( offsetName ); } }