Exception Handling in Lamda Expression

Posted by krrishbiju-15589 under C# on 1/6/2015 | Points: 10 | Views : 530 | Status : [Member] | Replies : 1
Hello,
Can anyone please explain how to handle exception handling in lamda expression.
I know in Anonymous method we can use try catch method like,

Employee emp= listemp.Find(delegate(Employee employee)
{
try
{
if (number == 5)
throw new InvalidCastException();

}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
return employee.id == 101;
}
By converting above code into Lamda expression we have,
Employee e1 = listemp.Find(x => x.id == 101);
My question is that can we implement try catch with this expression?

Thanks
Krrish




Responses

Posted by: Bandi on: 1/6/2015 [Member] [MVP] Platinum | Points: 25

Up
0
Down
refer
http://stackoverflow.com/questions/13593037/how-to-handle-exceptions-in-a-lambda-expression-within-a-task

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

krrishbiju-15589, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response