I know I could use a technique like in this question to get my method but I want to shortcut that process.
I'm looking for Enumerable.FirstOrDefault Method (IEnumerable)
I've tried both
var enumerableType = typeof(IEnumerable<>).MakeGenericType(typeof(string));
MethodInfo firstMethod = typeof(Enumerable)
.GetMethod("FirstOrDefault", new Type[] { enumerableType });
and
MethodInfo firstMethod = typeof(Enumerable)
.GetMethod("FirstOrDefault", Type.EmptyTypes);
But both return null
.
What would be the correct approach?
Aucun commentaire:
Enregistrer un commentaire