I am trying to make a dictionary in C # that uses a boolean array for its keys.
Dictionary<bool[], string>
the bool array has a fixed length of 1000 and all have the same length. I am having problems with a hash code, and the generic "exclusive" or "method doesn't make much sense because of the length of the array."
Similar StackOverflow questions are addressed using the "exclusive" or "GetHashCode method". I do not think this works in this context. I would like to use it like:
Dictionary<bool[], string> myDict = new Dictionary<bool[], string>(EqualityComparer);
where EquaityComparer does something like:
public class EqualityComparer : IEqualityComparer<bool[]> { public bool Equals(bool[] x, bool[] y) { return x.SequenceEqual(y); } public int GetHashCode(bool[] x) {
Of course, all the usual problems associated with changing the bool array, and the size of any derived key related to performance, are here ... although I have no solution.
source share