c# - Join two separate list into single list in MVC -


i have 2 separate ienumerable lists having dynamic values:

first list ienumerable<string> subheadid having data

 [0]->1  [1]->4 

second list ienumerable<string> subheadid having data like

 [0]->100  [1]->233 

i want join these 2 lists single list having data like

 [0]->1,100  [1]->4,233 

how can join lists. please guide.

thanks

the proper way achieve using zip() extension method:

        var firstlist = new list<string>() { "1", "4" };         var secondlist = new list<string>() { "100", "233" };          var combined = firstlist.zip(secondlist, (f, s) =>  f + ", " + s ).tolist(); 

it's important notice here that:

if happen have 2 collections unequal number of elements, zip method continue shortest index both elements exist. no errors occur if 2 collections uneven.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -