// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Linq; namespace E { public class Data { public int Id { get; set; } public string S { get; set; } } public class Program { public static void Main(string[] args) { List lst = new List(); lst.Add(new Data{Id=1, S="A"}); lst.Add(new Data{Id=1, S="B"}); lst.Add(new Data{Id=2, S="A"}); lst.Add(new Data{Id=2, S="B"}); var q1 = lst.Where(o => o.Id == 1).Select(o => o.Id); var q2 = lst.Where(o => !q1.Contains(o.Id)); foreach(var r in q2) { Console.WriteLine(r.Id + " " + r.S); } } } }