I have two local vars with the same raison d'etre, _lastShortName and _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;
. . .
Yet _lastCompanyName is grayed out where it is declared. Why would that be? Resharper > Inspect > Code Issues in Solution does not say it is an unused variable, so it must be Visual Studio that is doing the graying, but why?