Why does Silverlight for Windows Phone throw an exception when deriving a class from Dictionary<TKey, TValue> where the key parameter is an enum?
I'm really curious about the lower level reason for this restricti开发者_如何学编程on, documented here http://msdn.microsoft.com/en-us/library/xfhwa508(VS.95).aspx
Wow, that is strange...
Platform Notes
Silverlight for Windows Phone:
An exception is thrown when deriving a class from Dictionary where the TKey parameter is an enumeration.
I do that all the time in non-WP7 apps!
Maybe related to the way enums get special treatment or the "Caution" added here in July: http://msdn.microsoft.com/en-us/library/system.enum(VS.95).aspx
You should never create an enumeration type whose underlying type is non-integral. Although you can create such a type by using reflection, method calls that use the resulting type are unreliable and may also throw additional exceptions.
精彩评论