lundi 25 mai 2020

Check if a Type derives from a Interface with more than one Generic Argument

I have a question about loading types with reflection. I am attempting to filter the list of types in an Assembly by those which implement an interface with two generic parameters. I don't intend to explicitly tell which types are those generic parameters since I want all classes that implement the interface but whenever I attempt to use typeof(IExample<>) it gets marked as an error. However, it's possible to do it with an interface that only has one generic parameter. I would really appreciate some help with this! Thanks in advance :)

public interface IExample<T, E>
{
}

This is how my interface would looks like. And then I currently have to classes that implement it.

public class C 
{
}

public class A : IExample<string, C>
{
}

Public class B : IExample<XMLDocument, C>
{
}




Aucun commentaire:

Enregistrer un commentaire