I have two list that I want to get the different. So because CustomerId 1 is in both I only want to return CustomerId 2. I am using Except
but I a returning CustomerId 1 and 2 any help would be great
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
List<Participants> Participants1 = new List<Participants>();
Participants vm1 = new Participants();
vm1.CustomerId = 1;
vm1.FirstName = "Bill";
vm1.LastName= "Jackson";
Participants1.Add(vm1);
List<Participants> Participants2 = new List<Participants>();
Participants vm2 = new Participants();
vm2.CustomerId = 2;
vm2.FirstName = "Steve";
vm2.LastName= "Jackson";
Participants vm3 = new Participants();
vm3.CustomerId = 1;
vm3.FirstName = "Bill";
vm3.LastName= "Jackson";
Participants2.Add(vm2);
Participants2.Add(vm3);
var inFirstOnly = Participants2.Except(Participants1);
foreach(Participants item in inFirstOnly){
Console.WriteLine(item.CustomerId);
}
}
public class Participants
{
public int CustomerId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}