开发者

Why does Silverlight for Windows Phone throw an exception when deriving a class from Dictionary<TKey, TValue> where the key parameter is an enum?

开发者 https://www.devze.com 2023-01-23 18:58 出处:网络
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).aspxWow, that is strange...

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号