V
veerleverbr
Suppose having define an enum like this:
public enum SomeEnum
{
[DefaultValue("1")]
Something,
[DefaultValue("2")]
SomethingElse
}
Having a variable of the type ETransactionOwnerType, say:
SomeEnum test = SomeEnum.SomethingElse;
How can get this variable's default value?
string defaultValue = test. ??? // defaultValue should be "2"
I already tried looping through the values of the enum, but there
doesn't seem to be a method there that gives me the default value
either:
Type testEnum = Type.GetType("SomeEnum");
foreach(int value in Enum.GetValues(testEnum))
{
string name = Enum.GetName(testEnum, value);
}
// no method in the style of: Enum.GetDefaultValue(...)
public enum SomeEnum
{
[DefaultValue("1")]
Something,
[DefaultValue("2")]
SomethingElse
}
Having a variable of the type ETransactionOwnerType, say:
SomeEnum test = SomeEnum.SomethingElse;
How can get this variable's default value?
string defaultValue = test. ??? // defaultValue should be "2"
I already tried looping through the values of the enum, but there
doesn't seem to be a method there that gives me the default value
either:
Type testEnum = Type.GetType("SomeEnum");
foreach(int value in Enum.GetValues(testEnum))
{
string name = Enum.GetName(testEnum, value);
}
// no method in the style of: Enum.GetDefaultValue(...)