Home Dashboard Directory Help
Search

enum types should implement IEquatable<T> by Rüdiger Klaehn


Status: 

Closed
 as Won't Fix Help for as Won't Fix


17
0
Sign in
to vote
Type: Suggestion
ID: 374647
Opened: 10/10/2008 5:30:50 AM
Access Restriction: Public
0
Workaround(s)
view

Description

Enum types should implement IEquatable<T> so that they can be used as type parameters where there is a constraint for IEquatable<T>.

For example I have a user-defined dictionary type called Map<K,V> where K is IEquatable<K>. I was shocked to see that I could not use any enum as K.
Details
Sign in to post a comment.
Posted by Oleh Zheleznyak on 4/25/2012 at 12:50 PM
This is a major deficiency, without this CTS lacks consistency, there are also performance implications. This is illogical and counter-intuitive. Why does int, for instance, implement both IEquatable<int> and IComparable<int>, and Enum does not? In fact, if I'm not mistaken, ALL integral types, which enum can be based on do implement the aforementioned interfaces. Is there any sound argument why enum does not?
Posted by Fduch on 9/20/2011 at 10:09 PM
>Unfortunately, we are not making investments in this area in the current version of .NET.
Making an investment? Cool story, bro.
Meanwhile Dictionary<Enum, T> works 10+ time s slower.
Posted by Rüdiger Klaehn on 1/17/2011 at 2:58 AM
So you are not "making investments" in the most basic things like consistency of basic CLR types (System.Enum) with basic common interfaces like IEquatable<T>? Thanks for letting us know.

In turn, my company will no longer make investments in the .NET platform since it seems that you are much more interested in adding 20 new language features per release for maximum buzzword compliance than getting the foundations right.
Posted by Microsoft on 6/25/2010 at 10:55 AM
Thanks for the suggestion. Unfortunately, we are not making investments in this area in the current version of .NET. We are however, keeping the bug so that we can consider it in a future version of the product.

Best Regards,
Mircea Trofin,
Microsoft.
Posted by Microsoft on 12/5/2008 at 12:14 AM
Hi Rüdiger Klaehn,

Thanks for this suggestion. Having enum types implement IEquatable<T> as you suggest is a good idea, and one we'll look at implementing in a future release. I don't know if it will fit on the schedule for the next one, but I'm going to keep this issue active so that we can track it.

Thanks,
Melitta
Base Class Libraries Team
Sign in to post a workaround.