How to combine 2 lists using LINQ?

后端 未结 3 1408
一向
一向 2021-02-02 09:15

Env.: .NET4 C#

Hi All,

I want to combine these 2 lists : { \"A\", \"B\", \"C\", \"D\" } and { \"1\", \"2\", \"3\" }

into this o

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 09:32

    Essentially, you want to generate a cartesian product and then concatenate the elements of each 2-tuple. This is easiest to do in query-syntax:

    var cartesianConcat = from a in seq1
                          from b in seq2
                          select a + b;
    

提交回复
热议问题