C# Collection RemoveAt

Description

removes the element at the specified index of the Collection.

Syntax


public void RemoveAt(
  int index
)

Parameters

  • index - The zero-based index of the element to remove.

Example


using System;/*w  ww . ja v a  2 s.c  o  m*/
using System.Collections.Generic;
using System.Collections.ObjectModel;

public class Demo
{
    public static void Main()
    {
        Collection<string> myData = new Collection<string>();

        myData.Add("A");
        myData.Add("B");
        myData.Add("C");
        myData.Add("D");

        myData.RemoveAt(0);
        foreach( string item in myData )
        {
            Console.WriteLine(item);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections.ObjectModel »




Collection