Use Permutations of Data Sources - CSharp LINQ

CSharp examples for LINQ:Select

Description

Use Permutations of Data Sources

Demo Code


using System;/* w ww  .  j  a  v  a 2 s.co m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;

class MainClass
    {
        static void Main(string[] args)
        {
            // create the data sources
            string[] datasource1 = { "Oracle", "MySQL", "PLSQL", "pear" };
            int[]    datasource2 = { 21, 42, 37 };

            // perform the linq query
            var result = from e in datasource1
                         from f in datasource2
                         select new
                         {
                             e,
                             f
                         };

            foreach (var element in result)
            {
                Console.WriteLine("{0}, {1}", element.e, element.f);
            }
        }
    }

Result


Related Tutorials