码迷,mamicode.com
首页 > Windows程序 > 详细

c# 之入门简介1

时间:2019-01-09 21:47:05      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:thread   got   main   code   wrong   option   you   语句   case   

 

goto  语句

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _5._12跳转
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0;
            Console.WriteLine("5的阶乘等于几?请选择:");
            Console.WriteLine("1. 5!=5\n2. 5!=10\n3. 5!=20\n4. 5!=60");
        error:
            {
                a++;
                if (a > 1) Console.WriteLine("you are wrong!");
            }
            int option = int.Parse(Console.ReadLine());
            switch (option)
            {
                case 1:
                case 2:
                case 3:goto error;
                case 4:goto right;
                default:
                    Console.WriteLine("请重新选择。");
                    goto end;            }
        right:
            {
                Console.WriteLine("ok!!!!");
            }
        end:


            Console.ReadKey();
        }
    }
}

 

c# 之入门简介1

标签:thread   got   main   code   wrong   option   you   语句   case   

原文地址:https://www.cnblogs.com/Mengchangxin/p/10246610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!