ProductA[] fruits1 ={newProductA{ Name ="apple", Code =9},newProductA{ Name ="orange", Code =4},newProductA{ Name ="lemon", Code =12}};ProductA[] fruits2 ={newProductA{ Name ="apple", Code =9}};//Get all the elements from the first array//except for the elements from the second array.IEnumerable<ProductA> except =
fruits1.Except(fruits2);foreach(var product in except)
Console.WriteLine(product.Name +" "+ product.Code);/*
This code produces the following output:
orange 4
lemon 12
*/
public class ProductA: IEquatable<ProductA>{ public string Name { get; set; } public int Code { get; set; } public bool Equals(ProductA other) { if (other is null) return false; return this.Name == other