I have a interface variable IAction nextAction.
I want to see if the nextAction is of a concrete implementation, but was unsuccessful when I tried the following:
IAction nextAction = GetNextAction();
if (nextAction.GetType() != typeof(LastAction)) {
// do something...
}
any ideas on how I can determine the concrete type of the IAction variable nextAction?
I believe “is” is what you’re looking for. In general:
On second inspection, it looks like you’re trying to see if the action has changed
The only problem with this approach is if you have some kind of inheritance that you want to respect and you’re not concerned about an exact match (e.g. EventArg versus ClickEventArg would both be considered the same type since ClickEventArg derives from EventArg). If that is the case this SO answer might be of some help.