For sure, you won't get an
int
if
val
is declared as an enumeration and there is an item in the enumeration for that value.
If you want integer values, then get integer value! This is as simple as that!
foreach (int val in Enum.GetValues(typeof(ProgramDeclaration)))
{
MessageBox.Show(val.ToString());
}
By the way, this is well documented with samples in the documentation:
Enum.GetValues Method (Type) (System)[
^]
And it would even take less time to do F1 in Visual Studio to get online help that it take to write a question like this one.