LINQ list of sublist

Posted by Nelson on Stack Overflow See other posts from Stack Overflow or by Nelson
Published on 2010-04-01T19:12:13Z Indexed on 2010/04/01 19:23 UTC
Read the original article Hit count: 662

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#