记录一下:
SequenceEqual 只会检查它们是否引用了sme对象,如果你是内容相同,但是,是两个独立的对象,它们彼此都是并不相同,那么现在可以做的是覆盖Sequence中的Equal()
和==
运算符,检查其他属性进行比较
public bool Equals(Picture other)
{
if (other is null)
return false;return this.Id == other.Id && this.ProgramId == other.ProgramId && this.Left == other.Left && this.Top == other.Top && this.Width == other.Width && this.Height == other.Height && this.ResourcePath == other.ResourcePath;
}public override bool Equals(object obj) => Equals(obj as Picture);
public override int GetHashCode() => (Id, ProgramId, Left, Top, Width, Height, ResourcePath).GetHashCode();
原文链接:Enumerable.SequenceEqual 方法 (System.Linq) | Microsoft Learn