C# 泛型接口能否公开名称相同但签名参数不同的方法?

C# 泛型接口能否公开名称相同但签名参数不同的方法?,c#,generics,C#,Generics,我试图解码这个相当复杂的程序 有一个名为IInterface_1的通用接口。它公开了一个方法“MethodName”,它在方法签名中有一个参数 public interface IInterface_1<S> where S : class, "ISomeClass", new() { S MethodName(IEnumerable<Ilistname> Name); } public interface_1其中S:class,“isomoclass”,ne

我试图解码这个相当复杂的程序

有一个名为IInterface_1的通用接口。它公开了一个方法“MethodName”,它在方法签名中有一个参数

 public interface IInterface_1<S> where S : class, "ISomeClass", new()
{
    S MethodName(IEnumerable<Ilistname> Name);
}
public interface_1其中S:class,“isomoclass”,new()
{
S方法名(IEnumerable名称);
}
我希望继承IInterface_1的任何泛型类或接口都必须提供一个实现或路径来实现方法“MethodName”。如图所示,MethodName在方法签名中有一个参数

 public interface IInterface_1<S> where S : class, "ISomeClass", new()
{
    S MethodName(IEnumerable<Ilistname> Name);
}
然而,在程序的其他地方,相同的方法名称被另一个接口“IInterface_2”公开,其中方法签名中不是一个而是两个参数。在这两种情况下,约束与IIinterface_2从IIinterface_1继承的例外情况相同

public interface IInterface_2<S> : IInterface_1 where S : class, "ISomeClass", new()
{
    S MethodName(IEnumerable<Ilistname> Name, ISomethingElse Name_2);
}
public interface_2:i interface_1其中S:class,“isomoclass”,new()
{
S方法名称(IEnumerable名称、ISomethingElse名称_2);
}
IInterface_2在IInterface_1的RITS中,但IInterface_2和IInterface_1公开了相同的方法,但参数数量不同。从我对接口的了解来看,上述操作违反了接口“合同”,但该程序运行良好。我错过了什么

多谢各位
Tom

使用该接口组合的好处是,当某些类实现
IInterface_1
时,它只需要实现
S MethodName(IEnumerable Name)

如果它正在实现
IInterface_2
它需要同时实现这两个

S MethodName(IEnumerable<Ilistname> Name);
S MethodName(IEnumerable<Ilistname> Name, ISomethingElse Name_2);

但是我想说,这种设计的用法也很少见。

您必须在子类中提供显式接口实现。您只会有重载。并且您的c#无效。Jaroslav,根据您的回答,我能够找到一个声明为抽象的基类。在那个基类中,我能够找到“MethodName”,也被声明为抽象的。最后,在从基类继承的类中,有一个“MethodName”方法声明为override。因此,我相信,如果我是正确的,我只是没有看到继承链。