System.Contract.RequiresInRange C# (CSharp) Method

RequiresInRange() private method

private RequiresInRange ( int start, int length ) : void
start int
length int
return void
        public static void RequiresInRange(int start, int length)
        {
            if (!(start >= 0 && start < length)) {
                throw new ArgumentOutOfRangeException();
            }
        }

Usage Example

Esempio n. 1
0
 /// <summary>
 /// Fetches the element at the specified index.
 /// </summary>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// Thrown when the specified index is not in range (&lt;0 or &gt;&eq;length).
 /// </exception>
 public T this[int index]
 {
     get {
         Contract.RequiresInRange(index, Length);
         return(PtrUtils.Get <T>(
                    m_object, m_offset + (index * PtrUtils.SizeOf <T>())));
     }
     set {
         Contract.RequiresInRange(index, Length);
         PtrUtils.Set <T>(
             m_object, m_offset + (index * PtrUtils.SizeOf <T>()), value);
     }
 }
All Usage Examples Of System.Contract::RequiresInRange