Write a program in C# Sharp to generate a cartesian product of two sets
- برمجة سي شارب
- برمجة
- 2021-05-31
- ahmadghneem
الأجوبة
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();
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال