return different generics that implement same interface
问题 Considering there is a method static IEnumerable<IComparable> q() { return new List<string>(); } I am trying to achieve the same but on my own classes and as a result i receive casting error cs0266 I tried to cast this way return (Common<Message>)new A(); but it results InvalidCastException interface Common<T> where T : Message { T Source { get; } void Show(); } interface Message { string Message { get; } } class AMsg : Message { public string Message => "A"; } class A : Common<AMsg> { public