I want to filter objects in a List
using their type, using OfType<>. My problem is, that some objects are of a generic interf
from s in series
where s.GetType().GetGenericTypeDefinition()==typeof(ITraceSeries<>)
select s;
You can use reflection to achieve it:
var filteredList = myList.Where(
x => x.GetType()
.GetInterfaces()
.Any(i => i.IsGenericType && (i.GetGenericTypeDefinition() == typeof(ITraceSeries<>))));