Generic List Example

CSharp · Console

/Program.cs

using System;
using System.Collections.Generic;

public class Program
{
  public static void Main()
  {
    List<string> colors = new List<string>();
    colors.Add("Red");
    colors.Add("Green");
    colors.Add("Blue");
    colors.Remove("Green");

    Console.WriteLine("# of Colors: {0}", colors.Count);
    foreach (var color in colors) {
      Console.WriteLine(color);
	}
  }
}
;