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
Post a Comment