public interface PipelineElement<in TIn, out TOut>
{
IEnumerable<TOut> Run(IEnumerable<TIn> input, Action<Error> errorReporter);
}
public interface Stage
{
}
public abstract class PipelineElementBase<TIn, TOut> : PipelineElement<object, object>,
PipelineElement<TIn, TOut> where TIn : Stage where TOut : Stage
{
IEnumerable<object> PipelineElement<object, object>.Run(IEnumerable<object> input, Action<Error> errorReporter)
{
return this.Run(input.Cast<TIn>(), errorReporter).Cast<object>();
}
public abstract IEnumerable<TOut> Run(IEnumerable<TIn> input, Action<Error> errorReporter);
}
object
没有实现Stage
,因此既TIn
也不TOut
可能永远不会object
,对不对?那么为什么编译器会认为PipelineElement<object, object>
和PipelineElement<TIn, TOut>
可以变得相同?为什么这会导致CS0695?
编辑:是的,这是完全有可能在同通用接口多次来实现:
public interface MyInterface<A> { }
public class MyClass: MyInterface<string>, MyInterface<int> { }
我打消了我的意见,我没有什么用处。标记为最喜欢的,我想知道答案以及:)。 +1的问题,虽然! – bas 2013-03-09 23:19:04