// 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; namespace E { public class Rec { private int f1; private string f2; public Rec() : this(0, "") { } public Rec(int f1, string f2) { this.f1 = f1; this.f2 = f2; } public int F1 { get { return f1; } set { f1 = value; } } public string F2 { get { return f2; } set { f2 = value; } } public override string ToString() { return ("[" + f1 + "," + f2 + "]"); } } public class TestClass { public static void Main(string[] args) { List lst = new List(); lst.Add(new Rec(1, "A")); lst.Add(new Rec(2, "BB")); lst.Add(new Rec(3, "CCC")); foreach(Rec r in lst) { Console.WriteLine(r); } Rec f2 = lst.Find(delegate (Rec r) { return r.F1 == 2; }); Console.WriteLine(f2); Rec fbb = lst.Find(delegate (Rec r) { return r.F2 == "BB"; }); Console.WriteLine(fbb); } } }