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); }