Home > Article > Backend Development > What is the C# equivalent of Java's isInstance()?
java.lang.Class.isInstance() Determines whether the specified Object is compatible with assignment The object represented by this class
Java's isInstance() method is equivalent to IsAssignableFrom() in C#.
The other simplest method equivalent to isInstance() is -
bool res = (ob is DemoClass);
You can also use Type.IsInstanceOfType to achieve the same result -
ob.GetType().IsInstanceOfType(otherOb)
The above is the detailed content of What is the C# equivalent of Java's isInstance()?. For more information, please follow other related articles on the PHP Chinese website!