By using the answer from TcKs it can also be done with the following LINQ query:
bool isBar = foo.GetType().GetInterfaces().Any(x =>
x.IsGenericType &&
x.GetGenericTypeDefinition() == typeof(IBar<>));
More Related Contents:
- How to get the list of properties of a class?
- How do I get the path of the assembly the code is in?
- Set object property using reflection
- How to create a new object instance from a Type
- How do I use reflection to invoke a private method?
- Correct Way to Load Assembly, Find Class and Call Run() Method
- Find a private field with Reflection?
- How to Load an Assembly to AppDomain with all references recursively?
- How can I get all classes within a namespace?
- How to get a list of properties with a given attribute?
- Mapping object to dictionary and vice versa
- Get all derived types of a type
- Reflection – Getting the generic arguments from a System.Type instance
- Using Case/Switch and GetType to determine the object [duplicate]
- Use reflection to invoke an overridden base method
- Get a generic method without using GetMethods
- Resolve Type from Class Name in a Different Assembly
- Discovering derived types using reflection
- How do I create a generic class from a string in C#? [duplicate]
- Determine if a type is static
- Get member to which attribute was applied from inside attribute constructor?
- Using GetProperties() with BindingFlags.DeclaredOnly in .NET Reflection
- Finding property differences between two C# objects
- How Can I add properties to a class on runtime in C#?
- Look if a method is called inside a method using reflection
- Can I get parameter names/values procedurally from the currently executing function?
- How can I protect my private funcs against reflection executing?
- How do I check if a type provides a parameterless constructor?
- IsAssignableFrom() returns false when it should return true
- Why is the use of reflection in .NET recommended?