本文介绍了嗯?如果真实)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我只是使用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);


  1. if (true)真是愚蠢.
  2. 如果某天某人会在两行之间插入fileinfo=null;怎么办?
  1. if (true) is pretty silly.
  2. What if some day, someone will insert fileinfo=null; between the two lines?


:)


这篇关于嗯?如果真实)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 11:33