Linq find all with certain type

后端 未结 6 1561
离开以前
离开以前 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:31

    maybe you could use ...

            List list = new List();
            list.Add("string");
            list.Add(9);
    
            var allOfOneType = list.Where(i => i.GetType().Equals(typeof(string)));
    
        

    提交回复
    热议问题