Except() মেথড প্রথম সিকোয়েন্সে থাকা কিন্তু দ্বিতীয় সিকোয়েন্সে নাও থাকা এলিমেন্টগুলো রিটার্ন করে (সেট ডিফারেন্স)।
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
static void Main()
{
int[] arr = { 5, 10, 15, 20, 35, 40 };
int[] except = { 20, 35 };
Console.WriteLine("Initial List...");
foreach (int ele in arr) Console.WriteLine(ele);
IEnumerable res = arr.AsQueryable().Except(except);
Console.WriteLine("New List...");
foreach (int a in res) Console.WriteLine(a);
}
}
আউটপুট
Initial List... 5 10 15 20 35 40 New List... 5 10 15 40
ডুপ্লিকেট অটোমেটিক রিমুভ হয় (সেট সেমান্টিক্স)। কাস্টম কমপারার ব্যবহার করা যায়।