好的,这是一个非常基本的问题,但我只是遇到了它。考虑以下类:
public class WindowComparer: IComparer, Generic.IComparer<Window> { }
场景1:我通常会声明它的方式。
public int Compare (object x, object y)
{
return (this.Compare((Window) x, (Window) y));
}
public int Compare (Window x, Window y) {...}
场景 2:MSDN 文档通常声明它的方式。
int Collections.IComparer.Compare (object x, object y)
{
// [this.Compare] is not recognized. How to access this?
return (this.Compare((Window) x, (Window) y));
}
int Generic.IComparer<Window>.Compare (Window x, Window y) {...}
但是,在尝试方案 2 时,intellisense 会丢失 Compare 方法,并且编译器会引发错误,指出 Compare 方法不是 WindowComparer 的成员。我错过了什么?