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