利用goto,算出最小公倍數


            int number1=255, number2=800,number3=0,product=0;
            int temporarily = Math.Max(number1, number2);
            number2  = Math.Min(number1, number2);
            number1 = temporarily;
            product = number1 * number2;
            while1:
            number1 = number1 > number2 ? number1 : number2;
            number3 = number1 % number2;
            number1 = number2;
            number2 = number3;
            if (number2 != 0)
                goto while1;
            Console.Write(product/number1);

利用goto,算出最大公因數


            int number1=54, number2=24,number3=0;
            int temporarily = Math.Max(number1, number2);
            number2  = Math.Min(number1, number2);
            number1 = temporarily;
            while1:
            number1 = number1 > number2 ? number1 : number2;
            number3 = number1 % number2;
            number1 = number2;
            number2 = number3;
            if (number2 != 0)
                goto while1;
            Console.Write(number1);

利用goto,進行氣泡排序


                int[] list = new int[9] { 2, 4, 6, 7, 1, 9, 3, 8, 5 };
                int temporarily;
                Boolean  flag = true ; 
                int i=1;
                int j=1;
                for1:
                flag =false  ;
                j = 1;
                for2:                
                if (list[j] < list[j - 1])
                {    
                    temporarily  = list[j];
                    list[j] = list[j - 1];
                    list[j - 1] = temporarily;
                    flag = true ;
                }
                if (j<9-i)
                {
                    j += 1;
                    goto for2;
                }
                if (i < 8 && flag == true )
                {
                    i += 1;
                    goto for1;
                }
                j = 0;
                for3:
                Console.Write(list[j] + " ");
                j++;
                if (j < 9)
                    goto for3;

利用goto,印出九九乘法表


                  int X = 1;
                  int Y = 1;
                  for1:
                  Y = 1;
                  for2:
                  Y+= 1;
                  if (Y* X <= 9)                   
                    Console.Write(Y + "X" + X + "=0" + Y * X + " ");
                  else
                    Console.Write(Y + "X" + X + "=" + Y * X + " ");
                  if (Y <= 8)
                    goto for2;
                  X += 1;
                  Console.WriteLine();
                  if (X <= 9)
                    goto for1;

利用goto,印出倒三角形


                int triangle1 = 0;
                int triangle2 = 9;
                for1:
                triangle2 = 9;
                for2:
                triangle2 -= 1;
                Console.Write(0);
                if (triangle2 > triangle1)
                    goto for2;
                triangle1 += 1;
                Console.WriteLine();
                if (triangle1 < 9)
                    goto for1;

利用goto,印出正三角形



            int triangle1 = 1;
            int triangle2 = 1;
            for1:
            triangle2 = 1;
            for2:
            triangle2 += 1;
            Console.Write(0);
            if (triangle2 <= triangle1)
                goto for2;
            triangle1 += 1;
            Console.WriteLine();
            if (triangle1 < 10)
                goto for1;