using System.Collections.Generic;
public static void Main()
List<CustomerGroup> listA = new List<CustomerGroup>(){
new CustomerGroup {Id = 1, FirstName = "Anna", FamilyName = "Shrek", Quantity = 5, Discount = 10},
new CustomerGroup {Id = 2, FirstName = "Elsa", FamilyName = "Fiona", Quantity = 5, Discount = 10},
new CustomerGroup {Id = 3, FirstName = "Olaf", FamilyName = "Donkey", Quantity = 5, Discount = 10},
new CustomerGroup {Id = 4, FirstName = "Sven", FamilyName = "Dragon", Quantity = 5, Discount = 5},
new CustomerGroup {Id = 5, FirstName = "Kristoff", FamilyName = "Puss", Quantity = 5, Discount = 10},
new CustomerGroup {Id = 6, FirstName = "Sven", FamilyName = "Dragon", Quantity = 10, Discount = 15},
new CustomerGroup {Id = 7, FirstName = "Kristoff", FamilyName = "Puss", Quantity = 10, Discount = 30}
List<CustomerGroup> listB = new List<CustomerGroup>(){
new CustomerGroup { FirstName = "Anna", FamilyName = "Shrek", Quantity = 5, Discount = 10},
new CustomerGroup { FirstName = "Elsa", FamilyName = "Fiona", Quantity = 5, Discount = 8},
new CustomerGroup { FirstName = "Sven", FamilyName = "Dragon", Quantity = 5, Discount = 5},
new CustomerGroup { FirstName = "Kristoff", FamilyName = "Puss", Quantity = 5, Discount = 10},
new CustomerGroup { FirstName = "Sven", FamilyName = "Dragon", Quantity = 10, Discount = 15},
new CustomerGroup { FirstName = "Kristoff", FamilyName = "Puss", Quantity = 10, Discount = 30},
new CustomerGroup { FirstName = "Hans", FamilyName = "Farquaad", Quantity = 20, Discount = 40}
List<CustomerGroup> listC = listA.Except(listB, new EqualityComparer()).ToList();
Console.WriteLine(string.Join("\n",listC.Select(x => x.FirstName)));
class EqualityComparer : IEqualityComparer<CustomerGroup>
public bool Equals(CustomerGroup x, CustomerGroup y)
return x.FirstName == y.FirstName && x.FamilyName == y.FamilyName && x.Quantity == y.Quantity && x.Discount == y.Discount;
public int GetHashCode(CustomerGroup codeh)
public class CustomerGroup{
public int Id {get; set;}
public string FirstName {get; set;}
public string FamilyName {get; set;}
public int Quantity{get; set;}
public int Discount {get; set;}