jeudi 28 septembre 2017

Generic method info from List(T) by type and dynamic parsing

Is it possible to get methodInfo based on wanted type like this:

var wantedType = typeof(propertyReference);
var methodInfo = typeof(List<wantedType>).GetMethod("Contains", 
                    new[] { typeof(wantedType) });

...and also this:

var list ="(some, list, here)".Split(new[] { ',' }, 
               StringSplitOptions.RemoveEmptyEntries).Select(wantedType.Parse).ToList()

If yes, what would be the proper way to do it?





Aucun commentaire:

Enregistrer un commentaire