dimanche 24 mai 2020

How to reflect on a different delegate for a string type in C#?

How can one reflect on a different delegate for a string type in C#?

private static Func<string, T> TryGetParser<T>()
    {
        return typeof(T).GetMethod("Parse", new Type[] { typeof(string) })
            .CreateDelegate(typeof(Func<string, T>)) as Func<string, T>; 
    }




Aucun commentaire:

Enregistrer un commentaire