Skip to content
Discussion options

You must be logged in to vote

Because IEquatable<T> provides the method Equals(T), not Equals(IEquatable<T>).

You should just use b directly instead:

if(a is IEquatable<T> ae) _equal = ae.Equals(b);

And if you expect an oddball scenario where a and b have a common T but don't both implement IEquatable<T> you might extend this to:

if(a is IEquatable<T> ae) _equal = ae.Equals(b);
else if(b is IEquatable<T> be) _equal = be.Equals(a);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fitdev
Comment options

Answer selected by fitdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants