public static bool IsSubclassOfRawGeneric(Type toCheck, Type baseType) { while (toCheck != typeof(object)) { Type cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck; if (baseType == cur) { return true; } toCheck = toCheck.BaseType; } return false; } // example: var baseType = typeof(BaseDataMapper<>); var mappers = baseType.Assembly.GetTypes().Where(t => t.IsClass && t != baseType && IsSubclassOfRawGeneric(t, baseType));
335900cookie-checkC# check if class has generic base type