Horje
reflection get enum value C# Code Example
reflection get enum value C#
object underlyingValue = Convert.ChangeType(value, Enum.GetUnderlyingType(value.GetType()));
reflection get enum value C#
System.Type enumType = typeof(TestEnum);
System.Type enumUnderlyingType = System.Enum.GetUnderlyingType(enumType);
System.Array enumValues = System.Enum.GetValues(enumType);

for (int i=0; i < enumValues.Length; i++)
{
    // Retrieve the value of the ith enum item.
    object value = enumValues.GetValue(i);

    // Convert the value to its underlying type (int, byte, long, ...)
    object underlyingValue = System.Convert.ChangeType(value, enumUnderlyingType);

    System.Console.WriteLine(underlyingValue);
}




Csharp

Related
c# read file while writing Code Example c# read file while writing Code Example
What is the best way to lock cache in asp.net? Code Example What is the best way to lock cache in asp.net? Code Example
panning script c# on phone Code Example panning script c# on phone Code Example
c# .net core kendo dropdownlistfor enum Code Example c# .net core kendo dropdownlistfor enum Code Example
unity check if gameobject is inside collider Code Example unity check if gameobject is inside collider Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13