Just in case: I've little C# experience, but if this generic construction means the same thing it does in Java, then you must create a whole new List parametrized by the supertype. In other words, if every instance of Bangle
is also an instance of Akthud
, it does not follow that every List<Bangle>
is also a List<Akthud>
.
The reason for this is that you can have two references to this List<Bangle>
. If the second reference casts and then refers to it as a List<Akthud>
, then it is permitted to add an Akthud
to it - but now the first reference has a List<Bangle>
whose members are not all Bangle
s. Violation!
That being said, David B's answer should indeed do what you want, correctly, AFAICT. (It looks like a copy operation.)
[And if I'm misunderstanding the semantics of C# generics, I hope someone corrects me in a comment!]