1

I'm trying to convert a IList<IList<object>> to IList<object>, I mean to have a unique and one list where contains all the element (object) of the first one.

    public IList<IList<Page>> PMTs
    {
        get
        {
            var pmts = Processes.Select(x => x.PageMapTable)
                                .ToList();
            return pmts;
        }
    }

    public IList<Page> BlockMapTable
    {
        get
        {
            // Incomplete
            var btm = PMTs.Select(x => x.?? ..
        }
    }

Assuming that you want to flatMap/flatten the list<list<Page>>, you can do that with selectMany method, like so:

public IList<Page> BlockMapTable
{
    get
    {
        var btm = PMTs.SelectMany(x => x).ToList();
    }
}

if you want to read more about it, here is a great blog post about selectMany extension method

4

2 に答える 2

4

を flatMap/flatten したい場合list<list<Page>>、次のように selectMany メソッドでそれを行うことができます:

public IList<Page> BlockMapTable
{
    get
    {
        var btm = PMTs.SelectMany(x => x).ToList();
    }
}

詳細については、selectMany 拡張メソッドに関する素晴らしいブログ投稿をご覧ください。

于 2012-04-15T06:17:12.930 に答える
1
public IList<Page> BlockMapTable
    {
        get
        {
            return PMTs.SelectMany(p => p).ToList();
        }
    }
于 2012-04-15T06:17:17.447 に答える