Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以泛型接口为参数的泛型接口_C#_Generics_Interface - Fatal编程技术网

C# 以泛型接口为参数的泛型接口

C# 以泛型接口为参数的泛型接口,c#,generics,interface,C#,Generics,Interface,我正在尝试设计一个接口,以获取一个IEnumerable,使用另一个IEnumerable的一些附加数据对其进行增强,并返回第一个。比如: interface IEnhanceable<T> { IEnumerable<T> EnhanceWith(IEnumerable<aGenericType> foo); } 接口可识别 { IEnumerable EnhanceWith(IEnumerable foo); } 我正在考虑的一种方法是创建一个

我正在尝试设计一个接口,以获取一个
IEnumerable
,使用另一个
IEnumerable
的一些附加数据对其进行增强,并返回第一个。比如:

interface IEnhanceable<T>
{
    IEnumerable<T> EnhanceWith(IEnumerable<aGenericType> foo);
}
接口可识别
{
IEnumerable EnhanceWith(IEnumerable foo);
}

我正在考虑的一种方法是创建一个抽象的空模型类,所有其他模型类都将从中继承该类并将其作为参数传递。但是,我不确定这是否是正确的方法。

这种方法有什么问题<代码>IEnumerable EnhanceWith(IEnumerable foo)我编辑了这个示例,因此它可能更清晰。我希望将foo作为另一个泛型类型的IEnumerable。希望这会更清楚。仍然不清楚。。。我怀疑您正在询问如何编写泛型方法--
IEnumerable EnhanceWith(IEnumerable foo)
-请确认(并解释您在这样做时遇到的问题)。我将您编写的东西放入了我的代码中。让我大吃一惊的是,VS接受了这一点,但我不确定这里发生了什么。你能给我一些建议或者给我一些链接,这个方法叫做EnhanceWith,这里的结构是什么?也许这可以为你解释一下?如果没有,请尝试以下搜索-。