c# - Unreachable code detected. Why? -


im trying learn c# reading herbert schildt "c# 4.0 complete reference" , in 1 of examples have warning cs0162 unreachable code detected , underlined console. how fix , why happened?

using system; class prodsum {     static void main()     {         int prod;         int sum;         int i;         sum = 0;         prod = 1;         (i = 1; 1 <= 10; i++)         {            sum = sum + i;            prod = prod * i;         }         console.writeline("summ = " + sum);         console.writeline("prod = " + prod);         console.readkey();     } } 

1 <= 10 true, code follow loop never reached. meant i <= 10

for (i = 1; <= 10; i++) 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -