B. *_*non 6 .net c# boolean default default-value
使用此代码:
bool dataToAdd;
if (null == _priceComplianceDetailList) return dataToAdd;
Run Code Online (Sandbox Code Playgroud)
我收到编译错误," 使用未分配的局部变量'dataToAdd' "
所以我不得不明确地给布尔分配"假":
bool dataToAdd = false;
if (null == _priceComplianceDetailList) return dataToAdd;
Run Code Online (Sandbox Code Playgroud)
在上下文中:
private bool PopulateSheetWithDetailData()
{
bool dataToAdd = false;
if (null == _priceComplianceDetailList) return dataToAdd;
List<PriceComplianceDetail> _sortedDetailList =
. . .
return _sortedDetailList.Count > 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么有必要?bool的默认值是否为false?
归档时间: |
|
查看次数: |
851 次 |
最近记录: |