-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
This would make Try Catch MUCH less verbose to what it is now:
Since C# 6.0 we can have simple Lambda properties:
string name;
public string Name
{
get => name;
set => name = value;
}
public string FullName => $"{FirstName} {LastName}";
It would be VERY cool to have this kind of lambda available for Try Catch:
try => WebClient.DownloadFile(path);
catch(WebException ex) => Log(ex);
EDIT: This example shows the advantage much cleaner. Try the following code with current state of C#:
try
{
try => Foo();
catch(BarException) => return null;
}
catch(Exception e) => Log(e.Message);
finally => Free(UnmanagedResource);
If you compare how much boilerplate code was necessary for get;set before C#6.0 you can clearly see how how similar Try Catch is to that. This way code gets less verbose and more readable 👍
What do you think about Expression-bodied try catch?
HalidCisse, dangi12012, huoshan12345, philosaurus, chrisahill and 7 moretheunrepentantgeek, Joe4evr, cpplearner, stakx, iam3yal and 16 moreHalidCisse, magol, TheFanatr and asaf92
Metadata
Metadata
Assignees
Labels
No labels