jeudi 22 novembre 2018

How to cast to a generic type using reflection?

How do I cast to a generic enumerable type from a concrete type using reflection?

For example:

  public class Test: IEnumerable<Foo> {
      ...
  }

  //pseudo code of what I would like to do:
  Test t = new Test();
  IEnumerable<Foo> foo = (Enumerable<>).MakeGeneric(typeof(Foo)).From(t);





Aucun commentaire:

Enregistrer un commentaire