dimanche 31 janvier 2021

Returning an anonymous type from lamda/ Code explanation

This code comes from mr.Lukazoid member of stackoverflow. I would like to know how this works. is a bit strange for me how you call a method like this. What is the role of 'TResult'!

public static string[] Foo<T, TResult>(Expression<Func<T, TResult>> func)
{
    return typeof(TResult).GetProperties().Select(pi => pi.Name).ToArray();
}

Foo((Person x) => new { x.LastName, x.DateOfBirth });

Thanks a lot.





Aucun commentaire:

Enregistrer un commentaire