I have an enum like this:
public static class ExampleClass {
public enum ExampleEnum {
None,
Example0,
Example1
}
}
and i only got string of type and value. like:
const string Type = "ExampleClass.ExampleEnum";
const string Value = "Example0";
and i don’t have the "Type" of enum, so i can’t use like typeof(ExampleClass.ExampleEnum).
in this case, can i check if enum "ExampleClass.ExampleEnum" exists, and then "ExampleClass.ExampleEnum" has "Example0"?
if above is possible, can i get an object or index of specific enum value?
>Solution :
You can use reflection to get all enums in the assembly,
And then you could use Enum.IsDefined to check whether the value exists on a particular enum.
https://docs.microsoft.com/en-us/dotnet/api/system.enum.isdefined?view=net-6.0