Answer the question
In order to leave comments, you need to log in
When will Type.IsInstanceOfType(Type) and Type.IsAssignableFrom(Type) give different results with the same input parameter?
Hello. Type.IsInstanceOfType(Type) checks whether the current type is in the inheritance hierarchy of the object represented by the type, or if the current type implements the target type interface, and Type.IsAssignableFrom(Type) determines whether an instance of the specified type can be assigned to a target type variable. As far as I understand, the second method can, for example, tell us whether an int can be cast to a float , unlike the first one. But can these date methods produce different results if both types are classes.
Answer the question
In order to leave comments, you need to log in
I don't think it's worth bothering with it at all.
When there is an instance of an object, then you can check it through IsInstanceOfType, when only data types then IsAssignableFrom
the method can for example tell us if an int can be cast to a float
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question