位置:首頁 > 軟件操作教程 > 編程開發(fā) > C# > 問題詳情

System.Enum的方法

提問人:劉冬梅發(fā)布時間:2020-10-10

using System;

namespace App1

{

    class myApp

    {

        enum Fabric

        {

            Cotton = 1,

            Silk = 2

        }


        static void Main()

        {

            string fabStr = "Cotton";

            if (Enum.IsDefined(typeof(Fabric), fabStr))

            {

                Fabric fab = (Fabric)Enum.Parse(typeof(Fabric), fabStr);

                Console.WriteLine(Enum.GetName(typeof(Fabric), 2));

            }

        }

    }

}

繼續(xù)查找其他問題的答案?

相關(guān)視頻回答
回復(fù)(0)
返回頂部