Why compiler gives this error? What is bad that the code is not executed ??
Answer 1, Authority 100%
The compiler issues this error to alert the programmer that this code never will not be executed. It is necessary in order for no problems when you expect the execution of this string, but it is not achieved.
We can say that we are protected from a potential error that may occur as a result of the fact that the written code will not be executed.
Answer 2, Authority 25%
If it was not an error, but a warning (who generally read warnings?), Or did not report anything at all, then you could accidentally insert Return
, and wonder why you have The code does not work as you expect.
If you (now) do not need to be executed – Commit it or remove the code block into a separate method.