使用此代码:
bool dataToAdd;
if (null == _priceComplianceDetailList) return dataToAdd;
我收到编译错误,“使用未分配的本地变量'dataToAdd'”
所以我必须明确地将“假”分配给bool:
bool dataToAdd = false;
if (null == _priceComplianceDetailList) return dataToAdd;
在上下文中:
private bool PopulateSheetWithDetailData()
{
bool dataToAdd = false;
if (null == _priceComplianceDetailList) return dataToAdd;
List<PriceComplianceDetail> _sortedDetailList =
. . .
return _sortedDetailList.Count > 0;
}
为什么有必要? bool的默认值是否为false?