MT0
0
Q:

linq get objects of specific type in list

// LINQ selection by type of an object

Class Base{}
Class A : Base {}
Class B : Base {}

List<Base> collection = new List<Base>();
collection.Add(new A());
collection.Add(new B());
collection.Add(new A());
collection.Add(new A());
collection.Add(new B());

var ofTypeA = collection.OfType<A>();
0

New to Communities?

Join the community