If I have a method with a parameter that’s an interface, whats the fasts way to see if the interface’s reference is of a specific generic type?
More specifically, if I have:
interface IVehicle{} class Car<T> : IVehicle {} CheckType(IVehicle param) { // How do I check that param is Car<int>? }
I’m also going to have to cast after the check. So if there is a way to kill 2 birds with one stone on this one let me know.
To check if param is a
Car<int>you can use ‘is’ and ‘as’ as normal: