我有两个本地变量,具有相同的存在理由,< etre,_lastShortName和_lastCompanyName:
private string _lastShortName = String.Empty;
private string _lastCompanyName = String.Empty;
...which are used like this:
private void AddFillRateByDCByLocationRow(FillRateByDCByLocation
frbdcbl)
{
int rowToPopulate =
_xlSheetFillRateByDCByLocation.UsedRange.Rows.Count + 1;
// Don't want repeats of ShortName
if (!_lastShortName.Equals(frbdcbl.ShortName))
{
var shortNameCell =
(Excel.Range)_xlSheetFillRateByDCByLocation.Cells[rowToPopulate,
SHORTNAME_BYDCBYLOC_COL];
shortNameCell.Value2 = frbdcbl.ShortName;
shortNameCell.Font.Bold = true;
}
_lastShortName = frbdcbl.ShortName;
// ... or CompanyName
if (!_lastCompanyName.Equals(frbdcbl.CompanyName))
{
var companyNameCell =
(Excel.Range)_xlSheetFillRateByDCByLocation.Cells[rowToPopulate,
COMPANYNAME_BYDCBYLOC_COL];
companyNameCell.Value2 = frbdcbl.CompanyName;
companyNameCell.Font.Bold = true;
}
_lastCompanyName = frbdcbl.CompanyName;
. . .
然而_lastCompanyName在声明它的地方显示为灰色。那为什么会这样? Resharper>检查>解决方案中的代码问题并不是说它是一个未使用的变量,因此它必须是正在进行灰化的Visual Studio,但为什么呢?