You can use Enumerable.OfType
var newList1 = list.OfType<Object1>().ToList() var newList2 = list.OfType<Object2>().ToList() var newList3 = list.OfType<Object3>().ToList()
As Jon skeet mentioned in one of the comments, the above have problems when there is inheritance in the image (i.e., Object1 gets the form Object2). If so, the only option is to compare using type
var newList1 = list.Where(t=>t.GetType() == typeof(Object1)).ToList() var newList2 = list.Where(t=>t.GetType() == typeof(Object2)).ToList() var newList3 = list.Where(t=>t.GetType() == typeof(Object3)).ToList()
Tilak source share