List.Remove() : List « System.Collections.Generic « C# / C Sharp by API






List.Remove()

 

using System;  
using System.Collections.Generic;  
  
class MainClass {  
  public static void Main() {  
    List<char> lst = new List<char>();  
      
    Console.WriteLine("Initial number of elements: " +  
                       lst.Count);  
  
    Console.WriteLine();  
  
    Console.WriteLine("Adding 6 elements");  

    lst.Add('C');  
    lst.Add('A');  
    lst.Add('E');  
    lst.Add('B');  
    lst.Add('D');  
    lst.Add('F');  
  
    Console.WriteLine("Number of elements: " +  
                       lst.Count);  
  
    Console.WriteLine("Removing 2 elements");  
    // Remove elements from the array list.  
    lst.Remove('F');  
    lst.Remove('A');  
  
    Console.WriteLine("Number of elements: " +  
                       lst.Count);  
  }
}

   
  








Related examples in the same category

1.new List()
2.extends List
3.List.Add
4.List.AsReadOnly()
5.List.Capacity
6.List.ConvertAll
7.List.Count
8.List.ForEach