if/switch/while/do while/for/等サイクルおよび判断の簡単な使い方例


 int i = 3;
        //if     ===================================================
        if (i < 2)
            i = 3;
        else
            i = 4;
        Response.Write(i+"
"); //if , c# =, == i=3; if (i == 1) Response.Write("1"); else if (i == 2) Response.Write("2"); else if (i == 3) Response.Write("3"); else if (i == 4) Response.Write("4"); //switch ================================================= i = 2; switch (i) { case 1: Response.Write(" 1 "); break; case 2: Response.Write(" 2 "); break; case 3: Response.Write(" 3 "); break; case 4: Response.Write(" 4 "); break; default: // else, case break, break Response.Write(" 4 "); break; } //while ========================================== /* while , true, , while , , false */ i = 1; while (i < 51) { i=i+1; } Response.Write("
"+i+"
"); //do-while ================================================ /* , true , false*/ int j=1;int zyj=0; do { zyj=zyj+j; j=j+1; } while(j<101); Response.Write("1+2+3+...+100=" + zyj+"
"); //for ================================================== /* for( 1; 2; 3) * 、 、 * 1 */ for (i = 0; i < 10; i++) Response.Write(i+"
======"); // break/continue/return ================================= /* break switch、while、do while、for */ for (i = 0; i < 10; i++) if (i ==5) { break; } else Response.Write(i);