विधि को संकलित किए जाने पर संपत्ति को त्रुटि क्यों मिलती है?अमान्य भिन्नता: प्रकार पैरामीटर 'टी' को 'UserQuery.IItem <T> .ememist' पर contravariantly मान्य होना चाहिए। 'टी' covariant
public interface IFoo {}
public interface IBar<out T> where T : IFoo {}
public interface IItem<out T> where T: IFoo
{
// IEnumerable<IBar<T>> GetList(); // works
IEnumerable<IBar<T>> ItemList { get; set; } // Error!
}
त्रुटि:
Invalid variance: The type parameter 'T' must be contravariantly valid on 'UserQuery.IItem<T>.ItemList'. 'T' is covariant.
की संभावित डुप्लिकेट [टी contravariantly मान्य होना चाहिए] (https://stackoverflow.com/questions/5041664/t-must-be-contravariantly-valid) –