using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Switch_test
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("box sizes:1=small, 5=medium, 10=large");
            Console.WriteLine("请选择");
            string s = Console.ReadLine();
            int i = int.Parse(s);
            int c = 0;
            switch (i)
            {
                case 1:
                    c += 1;
                    break;
                case 5:
                    c += 5;
                    goto case 1;     //重要
                case 10:
                    c += 10;
                    goto case 1;
                default:
                    Console.WriteLine("无效的输入。请选择1,5,or 10");
                    break;
            }
            Console.WriteLine("谢谢!您的花费={0}",c);
        }
    }
}


本文转载:CSDN博客