Well, I was trying out this code snippet from
..
using System;
using System.Collecti ons;
public class SamplesArrayLis t {
public class myReverserClass : IComparer {
// Calls CaseInsensitive Comparer.Compar e with the parameters
reversed.
int IComparer.Compa re( Object x, Object y ) {
return( (new CaseInsensitive Comparer()).Com pare( y, x ) );
}
}
public static void Main() {
[snip]
}
}
Why do we have to explicitly qualify the Compare method as below
int IComparer.Compa re( Object x, Object y )
when we implement the Compare method of the IComparer interface?
If I remove qualification, and simply do
int Compare( Object x, Object y )
I get a compile time error which says:
"Cannot implement an interface member because it is not public."
I don't understand this. Please kindly advise. TIA.
..
using System;
using System.Collecti ons;
public class SamplesArrayLis t {
public class myReverserClass : IComparer {
// Calls CaseInsensitive Comparer.Compar e with the parameters
reversed.
int IComparer.Compa re( Object x, Object y ) {
return( (new CaseInsensitive Comparer()).Com pare( y, x ) );
}
}
public static void Main() {
[snip]
}
}
Why do we have to explicitly qualify the Compare method as below
int IComparer.Compa re( Object x, Object y )
when we implement the Compare method of the IComparer interface?
If I remove qualification, and simply do
int Compare( Object x, Object y )
I get a compile time error which says:
"Cannot implement an interface member because it is not public."
I don't understand this. Please kindly advise. TIA.
Comment