» C#: Determining whether a class implements certain interface


«
»

ASP.NET, Programmeren, technologie

C#: Determining whether a class implements certain interface

09.18.08 | 3 Comments

typeof(IMyInterface).IsAssignableFrom(myClassInstance.GetType());
typeof(IMyInterface).IsAssignableFrom(typeof(MyClass));

Type.IsAssignableFrom()

Return Value
Type: System.Boolean

true if c 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 that c implements, or if c is a generic type parameter and the current Type represents one of the constraints of c. false if none of these conditions are true, or if c is a null reference.

circle’s Notes: C#: Determining whether a class implements certain interface


3 Comments

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

:

:


«
»
16 queries. 0,477 seconds.