本文介绍了嗯?如果真实)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我只是使用ReSharper重构一些旧代码,建议我更改此代码:
Hi All,
I''m just refactoring some old code using ReSharper and it''s suggested I change this:
var fileinfo = new FileInfo(file);
if(fileinfo != null)
{
}
对此:
to this:
var fileinfo = new FileInfo(file)
if(true)
{
}
我不确定我是否明白这一点,我现在有一个愚蠢的时刻,但这实际上在评估什么呢?缺少对对象的明确引用使我有些困惑.
谢谢,
Jammer
I''m not sure I get this, I''m having a stupid moment but what is this actually evaluating? The lack of explicit reference to an object has confused me a bit.
Thanks,
Jammer
推荐答案
var fileinfo = FileInfo.CreateNew(file);
-
if (true)
真是愚蠢. - 如果某天某人会在两行之间插入
fileinfo=null;
怎么办?
if (true)
is pretty silly.- What if some day, someone will insert
fileinfo=null;
between the two lines?
:)
这篇关于嗯?如果真实)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!