NETMF / llilum

Development Platform for MSIL and UWP apps targeting Micro Controllers. Part of the .NET Micro Framework family.
Other
159 stars 52 forks source link

Dictionary does not work with enum types as key #188

Closed lt72 closed 8 years ago

lt72 commented 8 years ago

the comparer used does not use the proper conversions for enum <= => int.

workaround is to define a simple comparer such as:

    internal class YOURENUMComparer : IEqualityComparer<YOURENUM>
    {
        public bool Equals( YOURENUM x, YOURENUM y )
        {
            return (int)x == (int)y;
        }

        public int GetHashCode( YOURENUM obj )
        {
            return (int)obj;
        }
    }