声明变量,一定要用 var!时间:2023-03-09 18:03:30 public static T TryGet<T>(Func<T> func, T ifError = default(T)) { try { return func(); } catch { return ifError; } } string a;try{ a = doooooooooo(); } catch { a = "wrewre"; } //this is shit! var a = TryGet(doooooooooo, "wrewre"); //great!