Useful lamda exp
The lambda expression syntax in C# looks like this: The code begins with the set of parameters to the lambda expression. The => is the “goes to” or lambda operator. The remainder of the code is the expression itself. In this case, checking for the item in the list where CustomerId is 4. 2)... Customer foundCustomer = null; 3)... Customer foundCustomer = null;
foundCustomer = custList.FirstOrDefault(c =>
c.CustomerId == 4);
Debug.WriteLine(foundCustomer);
var query = from c in custList
where c.CustomerId == 4
select c;
foundCustomer = query.FirstOrDefault();
Debug.WriteLine(foundCustomer);
foreach (var c in custList)
{
if (c.CustomerId == 4)
{
foundCustomer = c;
break;
}
}
Debug.WriteLine(foundCustomer);
0 Response to "Useful lamda exp"
Post a Comment