forum

Home / DeveloperSection / Forums / Interface detection reflection

Interface detection reflection

Anonymous User171326-Mar-2014

I have this code in my C# module:

if (customer is IBuyer) { customer.WaiveServiceFee(); }

This compiles fine, as long as customer is an object that implements IBuyer. But the whole idea of using the conditional is to test whether the customer object implemented IBuyer. If it hasn't, I get a compile-time error that customer does not contain a definition for WaiveServiceFee (WaiveServiceFee is method that results from IBuyer implementation--it, of course, is not part of the customer class).

I'm not familiar enough with C# to know how I can apply the logic above to call WaiveServiceFee at run-time and also make the program compilable?

Thank you.


Updated on 26-Mar-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By