সাধারণ উপাদান −
পেতে Intesect পদ্ধতি ব্যবহার করুনতালিকা তৈরি করুন -
var list1 = new List{99, 87};
var list2 = new List{56, 87, 45, 99}; এখন, উপরের তালিকা থেকে সাধারণ উপাদানগুলি পেতে Intersect() পদ্ধতি ব্যবহার করুন −
list1.Intersect(list2);
এখানে সম্পূর্ণ কোড −
উদাহরণ
using System.Collections.Generic;
using System.Linq;
using System;
public class Demo {
public static void Main() {
// two lists
var list1 = new List<int>{99, 87};
var list2 = new List<int>{56, 87, 45, 99};
// common values
var res = list1.Intersect(list2);
foreach(int i in res) {
Console.WriteLine(i);
}
}
} আউটপুট
99 87