The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,926 other followers

.NET/C#: Type.IsSubclassOf Method versus Type.IsAssignableFrom

Posted by jpluimers on 2013/10/22

Every once in a while, you will have to do is checks using reflection.

Basically there are two methods:

Thanks to Ani and Werner Beroux for explaining the difference in more detail on StackOverflow, I added some extra links:

To check for assignability, you can use the Type.IsAssignableFrom method:


This will work as you expect for

but not when you are looking for ‘assignability’ across explicit / implicit conversion operators.

To check for strict inheritance, you can use Type.IsSubclassOf:



via: c# – How to check if a class inherits another class without instantiating it? – Stack Overflow.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: