mercredi 8 avril 2020

Passing dynamic argument into Linq ...OfType

I'm trying to do the following:

Type type = someObject.GetType();
if (someCollection.OfType<type>().Any())
{
    // some code
}

And the problem is that OfType<type>() only takes types directly like <T> and you can't pass it as an argument... is there something I can do to achieve the desired result?





Aucun commentaire:

Enregistrer un commentaire