声明变量,一定要用 var!
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!