Given this scenario
interface A {} class B : A {} A b = new B();
How can I verify that object b is created from interface A?
Try using
if(b is A) { // do something }
- Is this what you want?
You can test it like this:
var b = new B(); var asInterface = x as A; if (asInterface == null) { //not of the interface A! }
IS AS.
:
IMyInterface = instance as IMyInterface; if (intance != null) { //do stuff }
'as' - , 'is', - Impelments IMyInterface, .