The problem, as noted in several places that you do not assign iNumber or iVal, before using them for the first time (in your while operations). In this particular case, it is benign and assigns a default value that changes the thing. A mistake, though appropriate. Historically unassigned variables have been a headache in languages ββthat allow the use of unassigned variables. Especially in languages ββthat do not initialize the default storage location. In this case, C # initializes the default value, but may still make it difficult to find errors. The compiler is smart enough to check the path that the code takes before using the specific use of the local one, and if you can get there without assigning a value that it will complain about. This can help in complex code, where the code when reading sequentially leads to the fact that you think that the locale is assigned, but in fact, due to conditional logic, this is not
source share