LINQ | Set Operator | Except Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In LINQ, Set operators are those operators in query expression which return a result set based on the existence or non-existence of the equivalent elements within the same or different collections or sequences or sets. The standard query operator contains the following set operators: Union Intersect Except Distinct Except Operator The Except operator returns the set difference. Or in other words, we can say that it returns the set or collection which contain the elements that do not appear in the second collection or set. It does not support Query Syntax in C# and VB.Net languages. But you can use Except method on query variable or you can wrap your query in brackets and then call Except method. It support method syntax in both C# and VB.Net languages. It present in both the Queryable and Enumerable class. It is implemented by using deferred execution. When you are working with the collections of complex types, then you must use IEqualityComparer interface, otherwise, the Except method will give you incorrect result. Example 1: CSharp // C# program to find the difference // of the given sequences using System; using System.Linq; class GFG { static public void Main() { // Data source char[] sequence1 = {'m', 'q', 'o', 's', 'y', 'a'}; char[] sequence2 = {'p', 't', 'r', 's', 'y', 'z'}; // Display the sequences Console.WriteLine("Sequence 1 is: "); foreach(var s1 in sequence1) { Console.WriteLine(s1); } Console.WriteLine("Sequence 2 is: "); foreach(var s2 in sequence2) { Console.WriteLine(s2); } // Get the difference of the given // sequences Using Except function var result = sequence1.Except(sequence2); Console.WriteLine("New Sequence: "); foreach(var val in result) { Console.WriteLine(val); } } } Output: Sequence 1 is: m q o s y a Sequence 2 is: p t r s y z New Sequence: m q o a Example 2: CSharp // C# program to find the languages which is // not known by employees of the Department 2 using System; using System.Linq; using System.Collections.Generic; // Employee details // Department 1 public class Employee1 { public int emp_id1 { get; set; } public string emp_name1 { get; set; } public string emp_lang1 { get; set; } } // Employee details // Department 2 public class Employee2 { public int emp_id2 { get; set; } public string emp_name2 { get; set; } public string emp_lang2 { get; set; } } public class GFG { // Main method static public void Main() { List<Employee1> emp1 = new List<Employee1>() { new Employee1() {emp_id1 = 209, emp_name1 = "Anjita", emp_lang1 = "C#"}, new Employee1() {emp_id1 = 210, emp_name1 = "Soniya", emp_lang1 = "C"}, new Employee1() {emp_id1 = 211, emp_name1 = "Rohit", emp_lang1 = "Java"}, }; List<Employee2> emp2 = new List<Employee2>() { new Employee2() {emp_id2 = 290, emp_name2 = "Anjita", emp_lang2 = "C#"}, new Employee2() {emp_id2 = 212, emp_name2 = "MaMa", emp_lang2 = "Python"}, new Employee2() {emp_id2 = 233, emp_name2 = "Rima", emp_lang2 = "Java"}, }; // Query to find the languages that is not // known by employees of the department 2 // Using Except method var res = emp1.Select(e => e.emp_lang1).Except(emp2.Select(e => e.emp_lang2)); Console.WriteLine("Language: "); foreach(var val in res) { Console.WriteLine(val); } } } Output: Language: C Create Quiz Comment A ankita_saini Follow 0 Improve A ankita_saini Follow 0 Improve Article Tags : C# CSharp LINQ Explore IntroductionC# Tutorial 2 min read Introduction to .NET Framework 6 min read C# .NET Framework (Basic Architecture and Component Stack) 6 min read C# Hello World 2 min read Common Language Runtime (CLR) in C# 4 min read FundamentalsC# Identifiers 2 min read Data Types in C# 6 min read C# Variables 4 min read C# Literals 5 min read Operators in C# 7 min read C# Keywords 5 min read Control StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch) 5 min read C# Switch Statement 4 min read Loops in C# 4 min read C# Jump Statements (Break, Continue, Goto, Return and Throw) 4 min read OOP ConceptsClass and Objects in C# 4 min read Constructors in C# 5 min read C# Inheritance 3 min read Encapsulation in C# 2 min read C# Abstraction 4 min read MethodsMethods in C# 4 min read Method Overloading in C# 4 min read Method Parameters in C# 4 min read Method Overriding in C# 7 min read Anonymous Method in C# 2 min read ArraysArrays in C# 6 min read Jagged Arrays in C# 4 min read Array Class in C# 5 min read How to Sort an Array in C# | Array.Sort() Method Set - 1 8 min read How to find the rank of an array in C# 2 min read ArrayListArrayList in C# 6 min read ArrayList Class in C# 4 min read C# | Array vs ArrayList 2 min read StringStrings in C# 6 min read C# Verbatim String Literal - @ 5 min read C# String Class 9 min read C# StringBuilder 2 min read C# String vs StringBuilder 3 min read TupleC# Tuple 7 min read C# Tuple Class 3 min read C# ValueTuple 7 min read C# ValueTuple Struct 4 min read IndexersC# Indexers 5 min read C# Multidimensional Indexers 5 min read C# - Overloading of Indexers 3 min read Like