(Linq) Cross Join

C#/Winform 2017. 4. 14. 11:57
728x90
728x170
var queryfrom = from left in Enumerable.Range(1,4)
                            from right in Enumerable.Range(11, left)
                            select new {Left = left, Right = right};

            foreach (var pair in queryfrom)
            {
                Console.WriteLine("Left {0}, Right {1}", pair.Left, pair.Right);
            }

 

결과

Left 1, Right 11
Left 2, Right 11
Left 2, Right 12
Left 3, Right 11
Left 3, Right 12
Left 3, Right 13
Left 4, Right 11
Left 4, Right 12
Left 4, Right 13
Left 4, Right 14

 

728x90
그리드형

'C# > Winform' 카테고리의 다른 글

(.NET) awesome-dotnet  (0) 2017.04.14
(Linq) 점표기식  (0) 2017.04.14
(Linq) linq - join into  (0) 2017.04.14
(Linq) Linq to DataSet  (0) 2017.04.14
(Linq) linq to xml  (0) 2017.04.14
Posted by kjun.kr
,