I want to create pair, where new UnorderedPair(ObjA, ObjB) == UnorderedPair(ObjB, ObjA) returns true. I also want to avoid any (un)boxing.Have I gone about this in the correct way?public struct UnorderedPair<T> : IEquatable<UnorderedPair<T>>{    public T A;    public T B;    public UnorderedPair(T a, T b)    {        A = a;        B = b;    }    public override int GetHashCode()    {        return A.GetHashCode() ^ B.GetHashCode();    }    public bool Equals(UnorderedPair<T> other)    {        return (other.A.Equals(A) && other.B.Equals(B)) ||               (other.A.Equals(B) && other.B.Equals(A));    }    public override bool Equals(object obj)    {        return Equals((UnorderedPair<T>)obj);    }    public static bool operator ==(UnorderedPair<T> a, UnorderedPair<T> b)    {        return a.Equals(b);    }    public static bool operator !=(UnorderedPair<T> a, UnorderedPair<T> b)    {        return !(a == b);    }}
Is this an ok implementation of an UnorderedPair?
c#
One thing: I would make the struct immutable since mutable structs have really bad unintended effects. Otherwise, this is a good, solid implementation.public struct UnorderedPair<T> : IEquatable<UnorderedPair<T>>{    private readonly T a;    private readonly T b;    public UnorderedPair(T a, T b)    {        this.a = a;        this.b = b;    }    public T A    {        get        {            return this.a;        }    }    public T B    {        get        {            return this.b;        }    }    public override int GetHashCode()    {        return this.a.GetHashCode() ^ this.b.GetHashCode();    }    public bool Equals(UnorderedPair<T> other)    {        return (other.A.Equals(this.a) && other.B.Equals(this.b)) ||               (other.A.Equals(this.b) && other.B.Equals(this.a));    }    public override bool Equals(object obj)    {        return this.Equals((UnorderedPair<T>)obj);    }    public static bool operator ==(UnorderedPair<T> a, UnorderedPair<T> b)    {        return a.Equals(b);    }    public static bool operator !=(UnorderedPair<T> a, UnorderedPair<T> b)    {        return !(a == b);    }}