Mid LINQ

How to handle exceptions in LINQ?

How to handle exceptions in LINQ?

Use try-catch around enumeration, not the query:

try {

var result = employees.First(e => e.Salary > 999999);

} catch (Exception ex) {

Console.WriteLine("No match found.");

More from LINQ Tutorial

All questions for this course