0

I want to combine this two string values I have this LINQ code but I can't figure out how merge them I can only get the list by Object

List<string> All = new List<string>();

var _synopsis = ((IEnumerable<dynamic>)json.data.series.product
                                      .Where(x => x.synopsis !=null)
                                      .Select(x => x.synopsis).ToList());

var _number = ((IEnumerable<dynamic>)json.data.series.product
                                      .Where(x => x.number != null)
                                      .Select(x => x.number).ToList());

foreach (var a in _synopsis)
{
    All.Add(a);
}

foreach (var x in _number)
{
    All.Add(x);
}

I want the result become like this:

for example: 
_synopsis(TITLE) + _number(EPISODE)
result: TITLE + EPISODE

Here is the JSON structure: enter image description here

1 Answer 1

1

I'm assuming you are looking for something like this:

List<string> All = ((IEnumerable<dynamic>)json.data.series.product
    .Where(x => x.synopsis != null && x.number != null)
    .Select(x => x.synopsis + " + " + x.number)
    .ToList());
Sign up to request clarification or add additional context in comments.

3 Comments

Oh wow I actually tried it first but I got error after the .Select :) thank you so much I will try it now.
I got error from List<string> All == from your given code
invalid expression ==

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.