Home > Backend Development > C#.Net Tutorial > What is the C# equivalent of Java's isInstance()?

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

WBOY
Release: 2023-09-06 16:33:04
forward
1209 people have browsed it

C# 中相当于 Java 的 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);
Copy after login

You can also use Type.IsInstanceOfType to achieve the same result -

ob.GetType().IsInstanceOfType(otherOb)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template