Unnecessary assignment of value to 'definedVariable'
In Visual Studio, I have seen this message in a few of the exercises I have worked on.. Where the variable is initialized to 0 or empty...etc... and then I use it to have values assigned to that variable via a method. I see the variable grayed out on the initialization, with the following message "Unnecessary assignment of value to 'definedVariable'" It's suggested fix is to replace the variable with an underscore. eg. (only a sample) int x = 0; x = GetFactor(a); suggested change to int x = 0; _ = GetFactor(a); It doesn't throw a compiler error and it's not even really a warning... I do think it is kind of annoying... I don't change it because I want the clarity and I want to insure the variable is initialized with 0 or empty. vs having int x = GetFactor(a); Why is VS giving this suggestion? Is there a precedence that I am missing?