Skip to content

Instantly share code, notes, and snippets.

@xinmyname
Created September 5, 2013 18:27
Show Gist options
  • Select an option

  • Save xinmyname/6454141 to your computer and use it in GitHub Desktop.

Select an option

Save xinmyname/6454141 to your computer and use it in GitHub Desktop.
What if we had implicit try blocks in methods if you followed the method with a catch block? I think the meaning remains clear, but we lose a few lines and indentation.
private bool DoWork()
{
DoSomething();
DoSomethingElse();
return true;
}
catch (Exception ex)
{
_log.Error(ex);
return false;
}
// Instead of:
private bool DoWork()
{
try
{
DoSomething();
DoSomethingElse();
return true;
}
catch (Exception ex)
{
_log.Error(ex);
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment