-
Notifications
You must be signed in to change notification settings - Fork 1
Select
Hendrik Bulens edited this page Jul 21, 2021
·
2 revisions
static bool ParseId(Client client, out int number)
{
number = client.Id;
return true;
}
List<Customer> customers = new()
{
new Customer(1, "Hello", "World"),
new Customer(5, "Hello", "World"),
new Customer(15, "Hello", "World")
};
IEnumerable<int> identifiers = customers.SelectTry<Customer, Client, int>(x => new Client() { Id = x.Id }, ParseId);
int identifiersSum = identifiers.Sum(); // 21
IEnumerable<int> integerList = new List<int> { 1, 2, 3, 4, 5 };
IEnumerable<long> longList = integerList.ConvertTo<int, long>();
int count = longList.Count(); // 5