标签:bsp res 面向 重复 ram one string 异常处理 cache
class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } public string DosomeThing() { return "hello"; } public string GetSomeOne() { try { var result = DosomeThing(); //_logger.Information(result); return result; } catch (Exception e) { //_logger.Error(e.Message); return null; } } public string GetOtherOne() { try { var result = DosomeThing(); //_logger.Information(result); return result; } catch (Exception e) { //_logger.Error(e.Message); return null; } } }
class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } public string DosomeThing() { return "hello"; } public string GetOtherOne() { return TryRun<String>(() => DosomeThing()); } public T TryRun<T>(Func<T> action) { try { return action.Invoke(); } catch (Exception e) { //_logger.Error(e.Message); return default(T); } } }
标签:bsp res 面向 重复 ram one string 异常处理 cache
原文地址:https://www.cnblogs.com/fger/p/11362215.html