Enumerable.Distinct Method in C#
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.distinct?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Linq.Enumerable.Distinct%60%601);k(SolutionItemsProject);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.6.1);k(DevLang-csharp)%26rd%3Dtrue&view=netframework-4.8 public class Product { public string Name { get ; set ; } public int Code { get ; set ; } } // Custom comparer for the Product class class ProductComparer : IEqualityComparer < Product > { // Products are equal if their names and product numbers are equal. public bool Equals ( Product x, Product y ) { //Check whether the compared objects reference the same data. if (Object.ReferenceEquals(x, y)) return true ; //Check whether any of the compared objects is null. if (Object.ReferenceEquals(x, null ) || Object.ReferenceEquals(y, null )) ...