কম্পিউটার টিউটোরিয়াল

C# LINQ Intersect পদ্ধতি


Intersect() পদ্ধতি ব্যবহার করে দুটি অ্যারের মধ্যে সাধারণ উপাদানগুলো বের করুন।

নিচে আমাদের অ্যারেগুলো দেওয়া হলো -

int[] val1 = { 15, 20, 40, 60, 75, 90 }; int[] val2 = { 17, 25, 35, 55, 75, 90 };

ইন্টারসেকশন করার জন্য।

val1.AsQueryable().Intersect(val2);

সম্পূর্ণ উদাহরণটি নিচে দেখুন।

উদাহরণ

using System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       int[] val1 = { 15, 20, 40, 60, 75, 90 };       int[] val2 = { 17, 25, 35, 55, 75, 90 };       IEnumerable<int> res = val1.AsQueryable().Intersect(val2);       Console.WriteLine("Intersection of both the lists...");       foreach (int a in res)       Console.WriteLine(a);    } }

আউটপুট

Intersection of both the lists... 75 90

  1. C# LINQ FirstOrDefault পদ্ধতি

  2. সি শার্প Linq Where মেথড

  3. সি শার্প Linq Distinct() মেথড

  4. C#-এ Intersect মেথডের ব্যবহার