Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7870935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:45:35+00:00 2026-06-03T01:45:35+00:00

I have three (it’s possible to have more than 3-4 generic list, but in

  • 0

I have three (it’s possible to have more than 3-4 generic list, but in this example let 3) generic lists.

List<string> list1

List<string> list2

List<string> list3

all lists have same number of elements (same counts).

I used that for combining two lists with ZIP :

var result = list1.Zip(list2, (a, b) => new {
  test1 = f,
  test2 = b
}

I used that for foreach statement, to avoid foreach each List, like

foreach(var item in result){
Console.WriteLine(item.test1 + " " + item.test2);
}

How to use simmilary with Zip for three lists ?

Thanks

EDIT:

I want like:

List<string> list1 = new List<string>{"test", "otherTest"};

List<string> list2 = new List<string>{"item", "otherItem"};

List<string> list3 = new List<string>{"value", "otherValue"};

after ZIP (I don’t know method), I want to result (in VS2010 debug mode)

[0] { a = {"test"},
      b = {"item"},
      c = {"value"}
    }   

[1] { a = {"otherTest"},
      b = {"otherItem"},
      c = {"otherValue"}
    }  

How to do that ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:45:36+00:00Added an answer on June 3, 2026 at 1:45 am

    The most obvious way for me would be to use Zip twice.

    For example,

    var results = l1.Zip(l2, (x, y) => x + y).Zip(l3, (x, y) => x + y);
    

    would combine (add) the elements of three List<int> objects.

    Update:

    You could define a new extension method that acts like a Zip with three IEnumerables, like so:

    public static class MyFunkyExtensions
    {
        public static IEnumerable<TResult> ZipThree<T1, T2, T3, TResult>(
            this IEnumerable<T1> source,
            IEnumerable<T2> second,
            IEnumerable<T3> third,
            Func<T1, T2, T3, TResult> func)
        {
            using (var e1 = source.GetEnumerator())
            using (var e2 = second.GetEnumerator())
            using (var e3 = third.GetEnumerator())
            {
                while (e1.MoveNext() && e2.MoveNext() && e3.MoveNext())
                    yield return func(e1.Current, e2.Current, e3.Current);
            }
        }
    }
    

    The usage (in the same context as above) now becomes:

    var results = l1.ZipThree(l2, l3, (x, y, z) => x + y + z);
    

    Similarly, you three lists can now be combined with:

    var results = list1.ZipThree(list2, list3, (a, b, c) => new { a, b, c });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three dropdown list each dependent on previous one. How it is possible
i have three lists with the same number of elements in each other, i
I have three tables - notices, notices_read and companies. Notices contains a list of
I have three columns, each containing a list of email addresses that haven't opened
This could be a duplicate question, but I have no idea what search terms
I have three tables, places , place_user , users . I want to list
I have three tables in my Crystal Reports and it looks like this: Property
I have three classes (for example) Buick implements Vehicle Chevy implements Vehicle Ferrari implements
I have three tables : ImportBatch PatientChartImages PatientChartBatchMapping (this table has foreign key to
I have three ways of writing this code. The third way confuses me. First

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.