Linq find all with certain type

后端 未结 6 1599
离开以前
离开以前 2021-01-03 18:01

Is there a way to find in a List all items of a certain type with a Linq/Lambda expression?

Update: Because of the answers, I realize the question wasn\'t specific e

6条回答
  •  佛祖请我去吃肉
    2021-01-03 18:41

    Something like this (if using Linq to objects - it won't work with Linq to entities):

    var specificListOfTypes = from item in list
                                where item.GetType() == typeof(int)
                                select item;
    

提交回复
热议问题