Code Inspection: Assignment is not used
By analyzing the control flow of your code ReSharper is able to detect redundant initializers of fields and local variables. If the value you assign is not used until the next assignment is made in any of the execution paths, ReSharper suggests removing the redundant initializer.
This inspection also works when you assign a new value to a parameter that was never used beforehand. In this case, ReSharper doesn't suggest any fixes because it is not clear whether the parameter should be replaced with a local variable or whether the assignment is erroneous:
Redundant assignments can occur in different situations. For example, when a variable is initialized with the default value, or, like shown below, when some non-default value is assigned, but never gets used. Here you can see that
myDoc is initialized with a new instance of
XDocument, but the next line assigns it to either
b anyway, so the initially created object is nothing but a new task for the garbage collector.
Here is an example of a quick-fix suggested by this inspection: