c# 根据枚举Value 获得名称

// 定义枚举类型
enum sotype : int { book=1, pen=2, other=3 } // 输出名称 switch (Enum.GetName(typeof(sotype), 1)) { case "book": string strbook = "book"; //此时这个将被执行 break; default: break; }
原文地址:https://www.cnblogs.com/northeastTycoon/p/5704291.html