[英]C# - how do I find a key value inside an enum with a property?
Given the C# enum: 鉴于C#enum:
public enum options: byte
{
yes = 0,
no = 22,
maybe = 62,
foscho = 42
}
How do you retrieve the String 'maybe' if given the byte 62? 如果给出字节62,你如何检索字符串'maybe'?
您可以通过ToString()
将其强制转换为enum和retreive:
var result = ((options)62).ToString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.