Advertisement
Guest User

aaa

a guest
Jan 23rd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. public bool Remove(T value)
  2.         {
  3.             int indexOf = IndexOf(value);
  4.  
  5.             if(indexOf != -1)
  6.             {
  7.                 for (int i = indexOf; i < items.Length; i++)
  8.                 {
  9.                     if(i + 1 == items.Length - 1)
  10.                     {
  11.                         index--;
  12.                         return true;
  13.                     }
  14.                    
  15.                     items[i] = items[i + 1];
  16.                 }
  17.             }
  18.             return false;
  19.         }
  20.  
  21.         public void RemoveAt(int indexToRemove)
  22.         {
  23.             if (indexToRemove < items.Length)
  24.             {
  25.                 for (int i = indexToRemove; i < items.Length; i++)
  26.                 {
  27.                     items[i] = items[i + 1];
  28.                     if (i + 1 == items.Length - 1)
  29.                     {
  30.                         index--;
  31.                         return;
  32.                     }
  33.                 }
  34.             }
  35.         }
  36. public void Clear()
  37.         {
  38.             T[] newList = new T[4];
  39.             items = newList;
  40.             index = 0;
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement