The Except() method requires two collections. One collection on which Except method invoked and second collection which is passed as a parameter. The Except method returns the elements from first collection which do not exist parameter in the second collection.
using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; namespace program { class Example { public static void Main() { IList<string> List1 = new List<string>() { "aditya", "manoj", "kavita", "komal", "vimal" }; IList<string> List2 = new List<string>() { "aditya", "sohel", "vimal", "mayank", "mohit" };
var result = List1.Except(List2); Console.BackgroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.White; foreach (string str in result) Console.WriteLine(str);
Console.Read(); } } }
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The Except() method requires two collections.
One collection on which Except method invoked and second collection which is passed as a parameter.
The Except method returns the elements from first collection which do not exist parameter in the second collection.