Are the following code snippets equivalent?
class a
{}
class b:a
{}
b foo=new b();
//here it comes
foo is a
//...is the same as...
typeof(a).isinstanceoftype(foo)
Or maybe one of the other Type Methods map closer to the is operator. e.g. "IsAssignableFrom" or "IsSubclassOf"
It isn't, because is
is tolerant to null reference at the left-hand side.
It's not the same as is
is translated into the isinst opcode whereas IsInstanceOf
is a normal virtual call on Type
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With