using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
public static void Main()
List<int> list1 = new List<int>() { 1, 2, 3 };
List<int> list2 = new List<int>() { 4, 3, 1 };
List<Channel> list3 = new List<Channel>() {
new Channel{ChannelId=1, ChannelName="13angz", ProviderId="1"},
new Channel{ChannelId=3, ChannelName="13angz2", ProviderId="2"},
List<Channel> list4 = new List<Channel>() {
new Channel{ChannelId=3, ChannelName="13angz1", ProviderId="1"},
new Channel{ChannelId=4, ChannelName="13angz2", ProviderId="2"},
var uniqCh = list3.Except(list4, new ChannelComparer());
var nonIntersectingElements = list1.Except(list2);
if (nonIntersectingElements.Any())
Console.WriteLine($"The lists have {nonIntersectingElements.Count()} non-intersecting element(s):");
foreach (var ele in nonIntersectingElements)
Console.WriteLine("The lists have no non-intersecting elements.");
Console.WriteLine(uniqCh.Count());
public int ChannelId { get; set; }
public string ChannelName { get; set; }
public string ProviderId { get; set; }
public class ChannelComparer : IEqualityComparer<Channel>
public bool Equals(Channel x, Channel y)
return (x!.ChannelName == y!.ChannelName) && (x!.ProviderId == y!.ProviderId);
public int GetHashCode([DisallowNull] Channel obj)
return HashCode.Combine(obj.ChannelName, obj.ProviderId);