I’m trying to get all the sublists that don’t inherit from a specified class and also get the parent/root list type. I can’t quite figure out the syntax. Here’s an example of the sort of thing I’m looking for. Thanks for any help you can give!
public class Foo
{
public IList<Type> Bar { get; private set; }
}
List<Foo> test = new List<Foo>();
// Initialize, add values, etc.
var result = from f in test
from b in f.Bar
where !b.IsSubclassOf(typeof(AnotherClass))
select f.GetType(), b
Is this what you’re looking for?
…
Edit: If the type to exclude was a parameter, you could modify the where clause to be
IEnumarable<T>has an extension method ofOfType<>that would be useful when you want to limit selection to a given type, it would be nice if there was an exclusionary alternative (or if there is, I don’t know of it). If there were, you could use that on f.Bar and eliminate the where clause.