2015年11月5日 星期四

C4_10

using System;
namespace C4_10
{
    public class Progarm
    {
        public static void Main()
        {
            Console.WriteLine("請輸入你要顯示的時間類型:1代表星期,2代表年月日。");
            int x = Convert.ToInt32(Console.ReadLine());
            if (x == 1)
            {
                goto week;
            }
            else if (x == 2)
            {
                goto day;
            }
            else
            {
                goto other;
            }
        week:
            Console.WriteLine("今天是:{0}", DateTime.Now.DayOfWeek);
        return;
        day:
            Console.WriteLine("今天是:{0}",DateTime.Now);
        return;
        other:
            Console.WriteLine("你的輸入錯誤,你只能夠輸入1或2");
        return;
        }
    }
}

沒有留言: