c# - Why does Resharper offer to "Remove Unreachable Code" here? -


inspecting project i've inherited resharper, first suggested wrap this:

if (cellrng != null) 

...around code, cellrng acted on if it's not null. after doing that, tells me "if block" code not reachable, anyway. here code in context:

if (cellrng != null) {     cellrng.font.bold = true;     cellrng.value2 = ave.tostring(cultureinfo.invariantculture);     cellrng.numberformat = "##0.00";     cellrng.horizontalalignment = xlhalign.xlhaligncenter;     . . . } 

how can code both reference possibly null object (cellrng) , then, after check implemented, turn out null (code runs if not null considered unreachable)?

in second line below, resharper offers remove code, saying, "expression null"

cellrng = _xlsheet5.cells[rowidx, colcnt] range; if (cellrng != null) 

but how that? how range assigned cellrng seen null?

the code in if block following code above tagged resharper "code heuristically unreachable"

what czech!?!?!


Comments

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -

javascript - How to change image src on success AJAX -