|
Exemple 15-14 extrait du chapitre
Collections
Exemple 15-13< > Exemple 15-15
Cet exemple peut être compilé avec la ligne de commande: csc.exe /target:exe Exemple_15_14.cs Erreurs: 0 Avertissements: 0 Remarque:
Exemple_15_14.cs
using System.Collections.Generic;
public class Program {
public static void Main() {
List<int> list = new List<int>(3);
for (int i = 0; i < 8; i++){
list.Add(i);
System.Console.WriteLine("Count:{0} Capacité:{1}",
list.Count, list.Capacity );
}
list.TrimExcess();
System.Console.WriteLine("Count:{0} Capacité:{1}",
list.Count, list.Capacity );
}
}
Copyright Patrick Smacchia 2006 2007
|