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

  • Home
  • SEARCH
  • 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 79009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:04:41+00:00 2026-05-10T21:04:41+00:00

Say I have two lists: var list1 = new int[] {1, 2, 3}; var

  • 0

Say I have two lists:

var list1 = new int[] {1, 2, 3}; var list2 = new string[] {'a', 'b', 'c'}; 

Is it possible to write a LINQ statement that will generate the following list:

var result = new []{      new {i = 1, s = 'a'},     new {i = 1, s = 'b'},     new {i = 1, s = 'c'},     new {i = 2, s = 'a'},     new {i = 2, s = 'b'},     new {i = 2, s = 'c'},     new {i = 3, s = 'a'},     new {i = 3, s = 'b'},     new {i = 3, s = 'c'} }; 

?

Edit: I forgot to mention I didn’t want it in query syntax. Anyway, based on preetsangha’s answer I’ve got the following:

var result = list1.SelectMany(i =>  list2.Select(s => new {i = i, s = s})); 
  • 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. 2026-05-10T21:04:42+00:00Added an answer on May 10, 2026 at 9:04 pm

    preetsangha’s answer is entirely correct, but if you don’t want a query expression then it’s:

    var result = list1.SelectMany(l1 => list2, (l1, l2) => new { i = l1, s = l2} ); 

    (That’s what the compiler compiles the query expression into – they’re identical.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

lest say I have two lists List1: Tom, Frank, Lacey List2: Frank, Tom what
Say I have two strings, String s1 = AbBaCca; String s2 = bac; I
Let's say I have two arrays: int ArrayA[] = {5, 17, 150, 230, 285};
Lets say I have a simple table that only contains two columns: MailingListUser -
We have two lists, let's say students and their scores. I want to compare
Say I have two lists: >>> l1=[1,2,3,4] >>> l2=[11,12,13,14] I can put those lists
I have come across a small problem. Say I have two lists: list_A =
I have two lists with data that I want to compare dates for. I
Say I have two tables I want to join. Categories: id name ---------- 1
Lets say I have two tables - child and parent with many-to-one relation. What

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.