using Microsoft.Dynamics.ApplicationSuite.FinancialManagement.Currency.Framework; void demo(IExchangeRateProvider _provider) { if (_provider is ExchangeRateProviderCBOE) {} }
The operand on the left side of the ‘is’ or ‘as’ operator must be a table, class, or form.As I tested, neither managed interfaces nor managed classes (such as System.Object) can be used on the left side of ‘is’ and ‘as’ operators. I solved the problem by using Type.IsAssignableFrom() method. Simply using the ‘is’ operator would be nicer, but this does the job too.
void demo(IExchangeRateProvider _provider) { System.Object providerObj = _provider; if (providerObj.GetType().IsAssignableFrom(new ExchangeRateProviderCBOE().GetType())) {} }
Object obj = new ExchangeRateProviderCBOE(); if (obj is IExchangeRateProvider) {}