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

CsharpProgrammingServer Side Programming

The java.lang.Class.isInstance() determines if the specified Object is assignment-compatible with the object represented by this Class

Java’s isInstance() method’s equivalent in C# is IsAssignableFrom().

Another simplest way for isInstance() equivalent is −

bool res = (ob is DemoClass);

You can also work with Type.IsInstanceOfType for the same result −

Published on 31-Aug-2018 15:14:21