C#枚舉-通過值獲取名字,通過名稱獲取值


public enum ProtoType
{
    Move = 1,
    Enter = 2,
    Leave = 3,
    Attack,
    Die,
}

        print("ProtoType.Move:" + ProtoType.Move);
        print("ProtoType.Move.ToString():" + ProtoType.Move.ToString());
        print("Enum.GetName(typeof(ProtoType),3):" + Enum.GetName(typeof(ProtoType), 3));
        print("(ProtoType)(1):" + (ProtoType)(1));
        print("(ProtoType)(3):" + (ProtoType)(3));
        print("(ProtoType)(8):" + (ProtoType)(8));
        var arry = Enum.GetValues(typeof(ProtoType));
        foreach (var item in arry) { print(item); }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM