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
không thực hiện Stage
, do đó không phải TIn
cũng không TOut
bao giờ có thể là object
, phải không? Vậy tại sao trình biên dịch lại nghĩ rằng PipelineElement<object, object>
và PipelineElement<TIn, TOut>
có thể trở thành giống hệt nhau?Tại sao điều này dẫn đến CS0695?
EDIT: Vâng, nó là hoàn toàn có thể thực hiện cùng một giao diện chung nhiều lần:
public interface MyInterface<A> { }
public class MyClass: MyInterface<string>, MyInterface<int> { }
tôi loại bỏ ý kiến của tôi, tôi đã không có gì hữu ích. Đánh dấu là yêu thích, tôi cũng muốn biết câu trả lời :). 1 cho câu hỏi mặc dù! – bas