Not only this can lead to the same error.
if (RdoBtnBeepDefault.Checked) SystemSounds.Beep.Play(); else int i=0;
The reason is logic. If you put a single line statement in an else condition, which indirectly means that the conditional stream ends with this line. In this case, if you use any declaration || something, as indicated above, which does not make sense / influence in any way, which means that it is a string literal. This is not entirely true, but it is not. Mind C # visual studio editor reduces almost all possible errors and unnecessary memory usage.
When you set curly brackets, it indicates that you can use this variable in one block for some logic. Therefore, the editor will allow you to do this. At that time, VS suggests that you can add code in the future. So this will only give you a warning about this line. Without curly braces, he firmly assumes that you are not going to use this variable (due to scope). So she accepts this as a mistake.
source share