您的位置:首页 > 其它

声明变量,一定要用 var!

2016-11-22 03:17 176 查看
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!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: