Open vsfeedback opened 4 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
The same might probably apply to List<T>
. And perhaps IEqualityComparer<T>
would be a better choice than an IComparable
as only equality is needed here, not an ordering.
EDIT: Nevermind, mistook IComparable
for IComparer
.
I don't think we have existing IndexOf
methods that take an equality comparer. What's the proposal here? Is it the below?
public class Array
{
public static int IndexOf<T>(T[] array, T value, IEqualityComparer<T> equalityComparer);
public static int IndexOf<T>(T[] array, T value, int offset, int count, IEqualityComparer<T> equalityComparer);
}
Would it make more sense to be a LINQ extension method?
public static class Enumerable
{
public static int IndexOf<T>(this IEnumerable<T> enumerable, T value, IEqualityComparer<T> equalityComparer);
}
Somewhat related discussion about IndexOf
on IEnumerable<T>
: https://github.com/dotnet/runtime/issues/31156.
This issue has been moved from a ticket on Developer Community.
In an application I did not want to use bool Equals(Object^ b)override since it messed up Object.Reference equals in other parts. If I read the documentation right, Array uses equals to find a match, and with IComparable a zero would be a match. Would it be desirable to add such?
Original Comments
Feedback Bot on 4/1/2020, 08:20 PM:
Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.