I've got this code:
if (null == _priceComplianceSummaryList)
{
_priceComplianceSummaryList = new List<PriceComplianceSummary>();
}
Resharper flags it as an issue, suggesting, "Replace 'if' statement with respective branch" If I acquiesce, the code above changes to:
_priceComplianceSummaryList = new List<PriceComplianceSummary>();
Yet it seems R# is often more the belt-and-suspenders type of "cat," urging me to always check if something is null prior to referencing it. So is this ostensibly reckless behavior on its part really just a matter of efficiency? IOW, does "new List<>" only generate a new list if the istance variable (_priceComplianceSummaryList) is null, without having to explicitly check that?