Basically I wanna know if all the types in a particular namespace implements a particular interface like IEnumerable.
I know I can do:
foreach type ...
if type is IEnumerable
...
But I don’t wanna cast the type just to query if it implements an interface, because the cast will be thrown away either way.
Using the is operator is not a cast, it is a test, which sounds like what you want. Type casting in C# is done either using the forced casting operator (name?) like so:
or the safe casting operator: