Łukasz Gąsior
  • Home
  • now!
  • Blog
  • Po polsku
Social Links
Twitter
LinkedIn
Facebook
YouTube
Reddit
Instagram
GitHub
Medium
RSS
Łukasz Gąsior
  • Home
  • now!
  • Blog
  • Po polsku

Posts by tag

LINQ

1 post
  • Po polsku

Quick Tip: 04. przeszukuj kolekcje z where zamiast foreach

  • 2009-09-01

LINQ udostępnia metodę where, która umożliwia przeszukiwanie kolekcji tak jak foreach.
Przykładowo, zamiast:
[sourcecode language=”csharp”] var polishCustomers = new List<Customer>();
foreach (var customer in customers)
{
if (customer.Country == "Poland")
polishCustomers.Add(customer);
}
[/sourcecode] możemy użyć
[sourcecode language=”csharp”] var polishCustomers = customers.Where(x => x.Country == "Poland");
[/sourcecode] czyli krótko, zwięźle i na temat 🙂
Oczywiście wcześniej musimy dodać using System.Linq;

Share
click & help!
Nakarm dziecko!
Follow me
RESHARPER ESSENTIALS
ReSharper Essentials
CODINGTV();
codingtv();
Twitter Feed
Categories
  • Azure Cloud (6)
  • Po polsku (104)
  • Windows (1)
Featured Posts
  • Azure Activity Log – Change History
    • 2020-09-29
  • Diagram Driven Cloud Infrastructure with Cloud Maker
    • 2020-09-22
  • Azure ARM template, but it is not JSON!
    • 2020-09-15
About
👍 Cloud | DevOps | Development | Technical Leadership | 📗Author of "ReSharper Essentials
© 2019 Łukasz Gąsior. All rights reserved.
hosted with ♥️ on webio | Polityka prywatności

Input your search keywords and press Enter.