0

I have a problem with checking if in the inheritance of my class, the inherited class implements some interface

public interface IUserClass : IBaseInterface<T, K> { }
public class UserClass : BaseClass<A, B>, IUserClass { }

and I check

typeof(UserClass).IsAssignableFrom(typeof(IBaseInterface <,>))

and I get false. Even if I do

typeof(UserClass).IsSubclassOf(typeof(BaseClass<,>))

i get the same result Why ?

Tony
  • 12,405
  • 36
  • 126
  • 226
  • 1
    `IBaseInterface <,>` is an open generic type, which can't exist. You need to make it a closed generic in order for your code to ever return true. –  Aug 25 '17 at 13:17
  • I think, typeof(UserClass).BaseType.GetGenericTypeDefinition() == typeof(BaseClass<,>); is what your looking for – Immanuel Aug 25 '17 at 16:35

0 Answers0