You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
815 B
C#

using System;
using System.Linq;
using System.Collections.Generic;
class LinqExercise23
{
public static void Main(string[] args)
{
char[] charset1 = { 'X', 'Y', 'Z' };
int[] numset1 = { 1, 2, 3, 4 };
Console.Write("\nLINQ : Generate a Cartesian Product of two sets : ");
Console.Write("\n------------------------------------------------\n");
var cartesianProduct = from letterList in charset1
from numberList in numset1
select new { letterList, numberList };
Console.Write("The Cartesian Product are : \n");
foreach (var productItem in cartesianProduct)
{
Console.WriteLine(productItem);
}
Console.ReadLine();
}
}