To answer the 2nd part of your amended question, as TheRealSteveJudge has pointed out the value of
str
would be null.
More importantly if you then tried to use
str
after this point you would get an error
Quote:
Error 2 Use of unassigned local variable 'str'
and resharper would not be telling you that a
string str = string.empty
is redundant.
Basically you should EITHER ensure that
str
is initialised OR ensure that all the code paths result in a value being assigned to
str
Both Visual Studio and Resharper are helping you to both remove code that isn't necessary, and also helping you to find potential errors BEFORE you try to run your program.