Implementation de l'interface IComparer
bjr,
j'ai implémenté la classe crowdingDistanceComparateur qui implémente l'interface IComparer
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class crowdingDistanceComparateur : IComparer<Object>
{
public int compare(Object s1, Object s2)
{
if (s1 == null) return 1;
else if (s2 == null) return -1;
double distance1 = ((solution)s1).getCrowdingDistance();
double distance2 = ((solution)s2).getCrowdingDistance();
if (distance1 > distance2)
return -1;
else if (distance1 < distance2)
return 1;
else return 0;
}
}
} |
en exécutant le programme il me génère la faute suivante:
Citation:
'ConsoleApplication1.crowdingDistanceComparateur' n'implémente pas le membre d'interface 'System.Collections.Generic.IComparer<object>.Compare(object, object)'