一年12个月怎么划分属于四季中的哪个季节?(枚举enum简单应用)-c#编程小实例

济南网站建设 2022年12月20日06:16:36C#教程一年12个月怎么划分属于四季中的哪个季节?(枚举enum简单应用)-c#编程小实例已关闭评论1791阅读模式

【一年12个月怎么划分属于四季中的哪个季节?(枚举enum简单应用)】

关键代码:

namespace 枚举1
{


    public enum Season
    {
        春季,
        夏季,
        秋季,
        冬季


    }
    internal class Program
    {

       
        static void Main(string[] args)
        {

            Season mySeason1 = Season.冬季;
            Season mySeason2 = Season.冬季;
            Season mySeason3 = Season.春季;
            Season mySeason4 = Season.春季;
            Season mySeason5 = Season.春季;
            Season mySeason6= Season.夏季;
            Season mySeason7 = Season.夏季;
            Season mySeason8 = Season.夏季;
            Season mySeason9 = Season.秋季;
            Season mySeason10 = Season.秋季;
            Season mySeason11 = Season.秋季;
            Season mySeason12 = Season.冬季;
            Console.WriteLine("一月份是:"+mySeason1);
            Console.WriteLine("二月份是:" + mySeason2);


            Console.WriteLine("三月份是:" + mySeason3);
            Console.WriteLine("四月份是:" + mySeason4);
            Console.WriteLine("五月份是:" + mySeason5);
            Console.WriteLine("六月份是:" + mySeason6);

            Console.WriteLine("七月份是:" + mySeason7);
            Console.WriteLine("八月份是:" + mySeason8);
            Console.WriteLine("九月份是:" + mySeason9);
            Console.WriteLine("十月份是:" + mySeason10);
            Console.WriteLine("十一月份是:" + mySeason11);
            Console.WriteLine("十二月份是:" + mySeason12);

            Console.ReadKey();  

        }
    }
}

济南网站建设
  • 本文由 发表于 2022年12月20日06:16:36
  • 转载请务必保留本文链接:http://news.hcsw666.com/459