An example that uses List.Exists(Predicate match)

Over an internal alias someone asked for an example of List.Exists(Predicate match) … I thought you might find it fun and google might help me find it later when I need it ;-)

List<string> l = new List<string>();

l.Add("Red");

l.Add("Green");

l.Add("Blue");

l.Add("Purple");

//prints "true" as "Red" is in the list

Console.WriteLine(l.Exists(delegate(string s) { return s == "Red"; }));

//prnts "false" as "Pink" is not in the list

Console.WriteLine(l.Exists(delegate(string s) { return s == "Pink"; }));