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

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 374647 Comments
Status Closed Workarounds
Type Suggestion Repros 2
Opened 10/10/2008 5:30:50 AM
Access Restriction Public


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.
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,
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.

Base Class Libraries Team