Skip to content

Instantly share code, notes, and snippets.

@follesoe
Created December 24, 2010 14:17
Show Gist options
  • Select an option

  • Save follesoe/754265 to your computer and use it in GitHub Desktop.

Select an option

Save follesoe/754265 to your computer and use it in GitHub Desktop.
Learn the language, live the lifestyle
//Create a list of persons
List<Person> persons = new List<Person>();
persons.Add(new Person("Jonas", "Follesø"));
persons.Add(new Person("Hege", "Røkenes"));
persons.Add(new Person("Håvard", "Sørbø"));
persons.Add(new Person("Gøran", "Hansen"));
//... more persons go here .../
//C# 2.0 - Using an anonomous method to filter persons that starts with "J"
List<Person> jPersons = persons.FindAll(delegate(Person p) { return p.Name.StartsWith("J"); });
//C# 3.0 - Creating a function using lambda to filter persons that starts with "H"
List<Person> hPersons = persons.FindAll(p => p.Name.StartsWith("H"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment