C#输出早中晚,教科书的第一个程序

来源:互联网 发布:photoshopcs6 mac破解 编辑:程序博客网 时间:2024/05/16 16:01
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApplication1
{
    public enum TimeofDay
    { 
        Morning,
        Afternoon,
        Evening
    }
    class Program
    {
        static void WriteGreeting(TimeofDay timeofDay)
        {
            switch(timeofDay)
            {
                case TimeofDay.Morning:
                    Console.WriteLine("good morning!");
                    break;
                case TimeofDay.Afternoon:
                    Console.WriteLine("good afternoon!");
                    break;
                case TimeofDay.Evening:
                    Console.WriteLine("good evening!");
                    break;
            }
        }
        static void Main(string[] args)
        {
            WriteGreeting(TimeofDay.Morning);
            WriteGreeting(TimeofDay.Afternoon);
            WriteGreeting(TimeofDay.Evening);
            Console.Read();


        }
    }
}
0 0
原创粉丝点击