나는 거의 동일하지만 유일한 차이점은 func
, 다른 하나는 action
을 사용한다는 점입니다. 그리고 가능하면 그것들을 하나의 함수로 결합하고 싶습니다.void 반환과 함께 Func 작성하는 방법 #
private static void TryCatch(Action action)
{
try
{
action();
}
catch (Exception x)
{
Emailer.LogError(x);
throw;
}
}
private static TResult TryCatch<TResult>(Func<TResult> func)
{
try
{
return func();
}
catch (Exception x)
{
Emailer.LogError(x);
throw;
}
}
감사 :
이것은 내가 찾은 간단한 구문입니다. – CaffGeek