开发者

linq get all object in one-dimensional collection

开发者 https://www.devze.com 2022-12-29 19:13 出处:网络
public class Class1 : List<Class2> { } public class Class2 : List<Class3> { } public class Class3
public class Class1 : List<Class2>
{
}

public class Class2 : List<Class3>
{
}

public class Class3
{
    string str;
    int i;
}

public class Program
{
    Class1 c = new Class1();
    //insert values....

    List<Class3> all = ??;
}

How can i get a one-dimensional collection in my var "all" ? please n开发者_如何学运维ote I can not modify Class1, class2 and class3...


List<Class3> all = c.SelectMany(c2 => c2).ToList();
0

精彩评论

暂无评论...
验证码 换一张
取 消