You're using:
for (number = 1; number < 100; number = number++)
while you have to write
for (number = 1; number < 100; number++)
You should read these articles to understand why your source code did not increase: for , ++ Operator
In some test code, you can find out the behavior of the ++ operator:
int n = 0; Console.WriteLine(n); //0 n = n++; Console.WriteLine(n); //0 n = ++n; Console.WriteLine(n); //1 n = n++; Console.WriteLine(n); //1 n = ++n; Console.WriteLine(n); //2
Another nice example:
int n = 0; int x = n++; int y = ++n; Console.WriteLine(string.Format("x={0}", x)); //0 Console.WriteLine(string.Format("y={0}", y)); //2 Console.WriteLine(x + y); //n++ + ++n == 0 + 2 == 2 n = 0; x = ++n; y = n++; Console.WriteLine(string.Format("x={0}", x)); //1 Console.WriteLine(string.Format("y={0}", y)); //1 Console.WriteLine(x + y); //++n + n++ == 1 + 1 == 2
source share