G
Guest
I'm passing instance of List<DrawNode> to my method
AddRange(IEnumerable<DrawObject> objects)
But I got this error:
Argument '1': cannot convert from
'System.Collections.Generic.List<MyNamespace.DrawNode>' to
'System.Collections.Generic.IEnumerable<MyNamespace.DrawObject>'
I don't understand why does compiler complain, when List<> has IEnumerable<>
interface and DrawNode is inherited from DrawObject,
so both are just general types. So shouldn't they accept specific inherited
types without explicit cast?
Thank you for answer in advance.
AddRange(IEnumerable<DrawObject> objects)
But I got this error:
Argument '1': cannot convert from
'System.Collections.Generic.List<MyNamespace.DrawNode>' to
'System.Collections.Generic.IEnumerable<MyNamespace.DrawObject>'
I don't understand why does compiler complain, when List<> has IEnumerable<>
interface and DrawNode is inherited from DrawObject,
so both are just general types. So shouldn't they accept specific inherited
types without explicit cast?
Thank you for answer in advance.