0

I have an array of objects List<SlovnikWords>, here is the model:

class SlovnikWord
{
    public int Id { get; set; } = -1;
    public string Title { get; set; }
    public string Description { get; set; }
    public List<Word> Forms { get; set; }
    ...
}

And the model for Word is as follows

class Word
{
    public int Id { get; set; } = -1;
    public string Title { get; set; }
    public string Description { get; set; }
    ...
}

I need to create a list of all the Forms from all the original list of SlovnikWords, here's what I came up with:

var q = SlovnikData.Select(x => x.Forms);

This unfortunately creates an array of arrays, where as I only need one dimensional array of Forms without the outer one, i.e. a compound of x.Forms, please help.

1 Answer 1

3

This should do it:

var q = SlovnikData.SelectMany(x => x.Forms);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.