FirstOrDefault - Condition

Query
public void Linq62()
{
List products = GetProductList();

Product product789 = products.FirstOrDefault(p => p.ProductID == 789);

Console.WriteLine("Product 789 exists: {0}", product789 != null);
}
Lambda Expression
public void Linq62()
{
List products = GetProductList();

Product product789 = products.FirstOrDefault(p => p.ProductID == 789);

Console.WriteLine("Product 789 exists: {0}", product789 != null);
}
Output
Product 789 exists: False
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +