You should use a generic list instead of an ArrayList
:
class TestPays
{
public static List<Pays> LireRemplirPays() { //...blabla
return uneListe; // Cast here if necessary
}
static void Main(string[] args) {
List<Pays> paysList = LireRemplirPays();
paysList.Sort();
}
}
ArrayList
isn't generic and could contain any type of object, and object
doesn't implement IComparable
.
Also, if NomPays
doesn't actually do any checking, you can use the shorthand and not have to explicitly declare a backing field:
public string Nom { get; set; }