This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21460|Reply: 0

[Source] How to determine whether an instance inherits a parent class or implements a certain type of interface in C#

[Copy link]
Posted on 10/10/2016 12:55:30 PM | | |


Use the Type.IsAssignableFrom method

public   virtual   bool   IsAssignableFrom(Type   c);
parameter
c The type that compares to the current Type


Return value
true if the c parameter and the current Type represent the same type, or if the current Type is in the inheritance hierarchy of c, or if the current Type is an interface supported by c. If none of these conditions hold, or if c is an empty reference, false.





Previous:Create an account and password to log in to MongoDb
Next:C# dynamically loads the dll plugin and executes
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com