String.Compare dans un tableau

bibo90 -  
scriptiz Messages postés 1494 Statut Membre -
Bonjour,
AIDER MOI SVP !!! LE PROB EST QUE JE RENTRE DES DONNE DANS UNE PROPIETER DUNE CLASSE QUI SAPELLE AMIS!! ET JE VEU LES AFICHER PAR ORDRE ALPHABETIQUE !!

static void Main()
{
Amis[] tabamis = new Amis[3];
for (int i = 0; i < tabamis.Length; ++i)
{

tabamis[i] = new Amis();
Console.Write(" Entrer le Nom : ");
tabamis[i].Nom = Console.ReadLine();)

COMMENT JE FAIS POUR APPLIQUER LA METHODE STRING.COMPARE DANS LE TABLEAU ( tabamis[i].Nom )
POUR QUE JE PUISSE UTILISER LA METHODE ARRAY.SORT() APRES!!
POUR QUE JE PUISSE A LA FIN LES AFFICHER PAR ORDRE LES NOMS QUE JE RENTRE
OU UNE AUTRE SUGGESTION????

1 réponse

scriptiz Messages postés 1494 Statut Membre 425
 
Vu que ta propriété Nom semble publique, il te suffit d'y accéder ainsi pour comparer dans ce cas, le nom de ton ami en position 'i' avec celui en position 'i+1' :

tabamis[i].Nom.compareTo(tabamis[i+1].Nom);
0