How to manage lists in c# with list?

The List class provides several methods to manipulate lists of objects.

Example:


  List numbers = new List();
  numbers.Add(1);
  numbers.Add(2);
  numbers.Add(3);
  

Solution:

Using other methods like Remove, Contains, and Count:


  numbers.Remove(2);
  bool hasTwo = numbers.Contains(2);  // false
  int count = numbers.Count;          // 2
  

Beginner's Guide to C#