Why is Enum.GetValues() not available in the Windows Phone 7 API, and does this mean I should generally shy away from Enums in favor of structs or other mechanisms.
The GetValues method returns an array that contains a value for each member of the enumType enumeration. If multiple members have the same value, the returned array includes duplicate values.
Roughly, yes. There are two kind of reflection code, the general kind that goes through RuntimeType and the specific kind that uses dedicated CLR helper functions. The latter uses type info that can retrieved from the internal type representation that the CLR maintains. The fast kind.
I've run into this. For my purposes I was able to use reflection
foreach (var x in typeof(MyEnum).GetFields()) {
if (x.IsLiteral) {
// Do my stuff here
}
}
Really depends what you are doing with them though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With