Skip to content

Commit 3c4a705

Browse files
committed
修复哈希判断方法
1 parent 8ce66c8 commit 3c4a705

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/dotnetCampus.OpenXMLUnitConverter/EmuPoint.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public EmuPoint(Emu x, Emu y)
3131
/// <inheritdoc />
3232
public bool Equals(EmuPoint other)
3333
{
34-
return X.Equals(other.X);
34+
return X.Equals(other.X) && Y.Equals(other.Y);
3535
}
3636

3737
/// <inheritdoc />
@@ -43,21 +43,30 @@ public override bool Equals(object? obj)
4343
/// <inheritdoc />
4444
public override int GetHashCode()
4545
{
46-
return X.GetHashCode();
46+
unchecked
47+
{
48+
return (X.GetHashCode() * 397) ^ Y.GetHashCode();
49+
}
4750
}
4851

4952
/// <summary>
5053
/// 判断相等
5154
/// </summary>
52-
public static bool operator ==(in EmuPoint left, in EmuPoint right)
55+
/// <param name="left"></param>
56+
/// <param name="right"></param>
57+
/// <returns></returns>
58+
public static bool operator ==(EmuPoint left, EmuPoint right)
5359
{
5460
return left.Equals(right);
5561
}
5662

5763
/// <summary>
5864
/// 判断不相等
5965
/// </summary>
60-
public static bool operator !=(in EmuPoint left, in EmuPoint right)
66+
/// <param name="left"></param>
67+
/// <param name="right"></param>
68+
/// <returns></returns>
69+
public static bool operator !=(EmuPoint left, EmuPoint right)
6170
{
6271
return !left.Equals(right);
6372
}

0 commit comments

Comments
 (0)