I'm trying to compare 2 types.
I have class Foo<Bar>
but i dont know the generic arguments
I have to know is it a Foo
object or not.
The following code does not work, I dont know why.
foreach (var type in types.Where(t => t.BaseType == typeof(Foo<>))
{
use(type);
}
I found the answer.
There is a method called type.GetGenericTypeDefinition()
and I can compare my object with this methods return type now.