P
P
Pragma Games2021-11-30 20:29:01
C++ / C#
Pragma Games, 2021-11-30 20:29:01

Is there a difference between is and Type.IsAssignableFrom?

Hello. Is is sugar under the hood doing Type.IsAssignableFrom ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-11-30
@PragmaGames

No, it's not the same thing.
the is operator under the hood calls the isinst IL instruction
AND it works with object instances.

Test if obj is an instance of class, returning null or an instance of that class or interface.

https://sharplab.io/#v2:C4LglgNgPgAgTARgLACgYGYAE9...
https://en.wikipedia.org/wiki/List_of_CIL_instructions
And Type.IsAssignableFrom - works with an instance of Type, and does a lot of complex checks:
https://source .dot.net/#System.Private.CoreLib/Type...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question