reflection - What is the C# equivalent to Java's isInstance()? -


i know of is , as instanceof, reflective isinstance() method?

the equivalent of java’s obj.getclass().isinstance(otherobj) in c# follows:

bool result = obj.gettype().isassignablefrom(otherobj.gettype()); 

note while both java , c# work on runtime type object (java java.lang.class ≣ c# system.type) of obj (via .getclass() vs .gettype()), java’s isinstance takes object argument, whereas c#’s isassignablefrom expects system.type object.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -