using System;
/*
collections directive
*/
using System.Collections.Generic;
public class Program
{
public static void Main()
'List' declaration syntax:
'List<type> a = new List<type>();'
for the 'names' list, 'type' is 'string'
List<string> names = new List<string>();
new list members are added with the 'Add' method
the method accepts a string as argument
names.Add("Vitruvius");
names.Add("Alberti");
names.Add("Brunelleschi");
names.Add("Palladio");
names.Add("Palladio"); // lists may include duplicates
access list members by index, like arrays
the 'Count' field keeps track of the number of list members
like arrays, list indices start at 0
names[names.Count - 2] = "Borromini";
'LastIndexOf' retrieves the index of the last occurrence of a search string
names[names.LastIndexOf("Palladio")] = "Pisano";
'foreach' is convenient way to iterate over members in a collection
foreach (string name in names)
Console.WriteLine(name);
}