I have the following problem. I created the class attached below, but send me the following error:
Error: 'Tripolis.Compara' does not implement interface member
'System.Collections.Generic.IComparer
C:\Curso_5\Tripolis\Compara.cs 9 16Tripolis
Although I tried to find a solution in the network I have not managed to find it.
I hope someone on the forum can help me.
Thanks in advance.
ipadillar
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
using System.Collections.Generic;
namespace Tripolis
{
public class Compara : IComparer
{
public int Method1(string _parametro1, string _parametro2)
{
return parametro1.Length.CompareTo(parametro2.Length);
}
}
}
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
Translated into spanish:
Hola a todos.
Tengo el siguiente problema. He creado la clase que adjunto más abajo, pero me envía el siguiente error:
Error: 'Tripolis.Compara' does not implement interface member
'System.Collections.Generic.IComparer
C:\Curso_5\Tripolis\Compara.cs 9 16Tripolis
Aunque he intentado buscar un solución en la red no la he sabido encontrarla.
Espero que alguien en el foro me pueda ayudar.
Gracias por adelantado.
ipadillar
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
using System.Collections.Generic;
namespace Tripolis
{
public class Compara : IComparer
{
public int Method1(string _parametro1, string _parametro2)
{
return parametro1.Length.CompareTo(parametro2.Length);
}
}
}
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
VulpesPosted Aug 26, 2011, 6:38 AM
This is because the method name needs to be exactly the same as the interface method it's implementing.
Isidro PadillaPosted Aug 26, 2011, 10:12 AM
Translated into Spanish:
Gracias Vulpes, ahora funciona.
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
using System.Collections.Generic;
namespace Tripolis
{
public class Compara : IComparer
{
public int Compare(string _parametro1, string _parametro2)
{
return _parametro1.Length.CompareTo(_parametro2.Length);
}
}
}
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
ipadillar
VulpesPosted Aug 26, 2011, 8:06 AM
Isidro PadillaPosted Aug 26, 2011, 7:27 AM
I made the changes suggested by you but does not work either.
Error:'Compara': member names cannot be the same as their enclosing type
Translated into spanish:
Hola Vulpes,
He hecho los cambios que me has propuestos pero no funciona tampoco.
Error:'Compara': member names cannot be the same as their enclosing type
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
using System.Collections.Generic;
namespace Tripolis
{
public class Compara : IComparer
{
public int Compara(string _parametro1, string _parametro2)
{
return _parametro1.Length.CompareTo(_parametro2.Length);
}
}
}
oooooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooo
Thank you
ipadillar