我有这个枚举:
namespace J.Enums
{
public enum TH
{
Light = 0,
Dark = 1
}
public static partial class Extensions
{
public static string Text(this TH theme)
{
switch (theme)
{
default:
case TH.Light: return "Light";
case TH.Dark: return "Dark";
}
}
public static TH ToTheme(this string theme)
{
switch (theme)
{
default:
case "Light": return TH.Light;
case "Dark": return TH.Dark;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个变量a,如下所示:
var a = 88;
Run Code Online (Sandbox Code Playgroud)
如何确定a的值是否为Enum的有效值?在这种情况下,不会。