Marc,
| Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ?
I don't know, I thought they should...
In addition to other comments, consider using EqualityComparer(Of T) within
your generic class/method. Something like:
using System.Collections.Generic;
static T Something<T>(T value1, T value2)
{
if (EqualityComparer<T>.Default.Equals(value1, value2))
return value1;
else
return value2;
}
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Marc Gravell" <ma**********@gmail.com> wrote in message
news:el****************@TK2MSFTNGP04.phx.gbl...
| This one stumped me while refactoring some code to use generics...
|
| Suppose I declare an enum MyEnum {...}
|
| Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ?
|
| Of course, I can cast a MyEnum instance down to the int / short whatever
| (since int implements IEquatable<int>), but I don't like doing that, as it
| feels a bit messy, and I am then propegating the things that know what the
| base represenation is...
|
| Am I missing something? Is this just an oversight?
| (For ref, I am using IEquatable<T> to avoid having to use == since
operators
| cannot be expressed in the delegate declaration).
|
| Marc
|
|