C# Lists

List<T> is a resizable array from System.Collections.Generic. The T is the element type, so List<int> holds only integers, and the compiler rejects anything else.

C#
using System;
using System.Collections.Generic;

class Program {
  static void Main() {
    var scores = new List<int> { 82, 91, 76 };
    scores.Add(95);
    int total = 0;
    foreach (int score in scores) {
      total += score;
    }
    Console.WriteLine(scores.Count);
    Console.WriteLine(total);
  }
}
Read the full lesson