SHARE
TWEET

Untitled

a guest Sep 12th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public class CollectionEnumerator<T>
  2.     {
  3.         int position = -1;
  4.         List<T> items;
  5.         public void Reset()
  6.         {
  7.             position = -1;
  8.         }
  9.         public void Dispose() { }
  10.  
  11.         public CollectionEnumerator(List<T> new_items)
  12.         {
  13.             items = new List<T>();
  14.             items = new_items;
  15.         }
  16.  
  17.         public T Current
  18.         {
  19.             get
  20.             {
  21.                 if (position == -1 || position >= items.Count || (items[position] as Freight).Weight > 0.01)
  22.                     throw new InvalidOperationException();
  23.                 return items[position];
  24.             }
  25.         }
  26.  
  27.         public bool MoveNext()
  28.         {
  29.             if (position < items.Count - 1)
  30.             {
  31.                 position++;
  32.                 return true;
  33.             }
  34.             else
  35.                 return false;
  36.         }
  37.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top