System.Collections.ArrayList.RemoveAt C# (CSharp) Method

RemoveAt() public method

public RemoveAt ( int index ) : void
index int
return void
        public virtual void RemoveAt(int index)
        {
            if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
            Contract.Ensures(Count >= 0);
            //Contract.Ensures(Count == Contract.OldValue(Count) - 1);
            Contract.EndContractBlock();

            _size--;
            if (index < _size)
            {
                Array.Copy(_items, index + 1, _items, index, _size - index);
            }
            _items[_size] = null;
            _version++;
        }

Usage Example

		/// <summary>
		/// Simple and fast label collision detection.
		/// </summary>
		/// <param name="labels"></param>
		public static IEnumerable SimpleCollisionDetection(IList labels)
		{
            ArrayList labelList = new ArrayList(labels);

			labelList.Sort(); // sort labels by intersection tests of the label's collision box

			//remove labels that intersect other labels
			for (int i = labelList.Count - 1; i > 0; i--)
			{
                Label2D label1 = labelList[i] as Label2D;
                Label2D label2 = labelList[i - 1] as Label2D;

                if (label1 == null)
                {
                    labelList.RemoveAt(i);
                    continue;
                }

                if (label1.CompareTo(label2) == 0)
				{
                    if (label1.Priority > label2.Priority)
					{
						labelList.RemoveAt(i - 1);
					}
					else
					{
						labelList.RemoveAt(i);
					}
				}
			}

			return labelList;
		}
All Usage Examples Of System.Collections.ArrayList::RemoveAt