Why does a Linq Cast operation fail when I have an implicit cast defined?

Because, looking at the code via Reflector, Cast doesnt attempt to take any implicit cast operators (the LINQ Cast code is heavily optimised for special cases of all kinds, but nothing in that direction) into account (as many .NET languages won’t).

Without getting into reflection and other things, generics doesnt offer any out of the box way to take such extra stuff into account in any case.

EDIT: In general, more complex facilities like implicit/explict, equality operators etc. are not generally handled by generic facilities like LINQ.

Leave a Comment