.net(枚举和switch结构)

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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
           
            Gender sex = Gender.F;
            switch (sex)
            {
                case Gender.M:
                    Console.WriteLine("性别为男");
                    return;
                case Gender.F:
                    Console.WriteLine("性别为女");
                    break;
                default:
                    break;
            } 

            Console.WriteLine(getFood());
        }

        public static string getFood()
        {
            return 1 + 1 > 3 ? "鸡翅" : "鸡腿";
        }
    }

    enum Gender
    {
        M,
        F
    }
}

原文地址:https://www.cnblogs.com/wjchang/p/3671599.html