Last active
February 19, 2019 00:49
-
-
Save mishrsud/c8eed9afd99270d8f0e66243752fa8d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Great explanation on Stackoverflow: https://stackoverflow.com/a/1710395/190476 | |
void Main() | |
{ | |
Predicate<Person> personWithId1 = person => person.Id == 1; | |
Predicate<Person> personsOver30 = person => person.Age > 30; | |
var persons = new List<Person> | |
{ | |
new Person { | |
Id = 1, | |
Age = 35, | |
Name = "Thirty Five" | |
}, | |
new Person { | |
Id = 2, | |
Age = 24, | |
Name = "Twenty Four" | |
}, | |
new Person { | |
Id = 3, | |
Age = 30, | |
Name = "Thir Ty" | |
}, | |
new Person { | |
Id = 4, | |
Age = 40, | |
Name = "For Ty" | |
}, | |
}; | |
persons.Find(personWithId1).Dump("Id 1"); | |
persons.FindAll(personsOver30).Dump("Over 30"); | |
} | |
// Define other methods and classes here | |
class Person | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public int Age { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment