完全一致的话遍历equal就可以 但是元素一致排序不一致呢
想法1 先排序再遍历一致 list的排序blog.csdn.net/jimo_lonely… 排序然后再Enumerable.SequenceEqual
List<string> codeLabelsBefore = new List<string>();
foreach (var codeSection in sectionControl.CodeSections)
{
codeLabelsAfter.Add(codeSection.CodeSectionLabel);
}
foreach (var codeSection in mOriginCodeSection)
{
codeLabelsBefore.Add(codeSection.CodeSectionLabel);
}
if ((codeLabelsAfter.Count == 0) && (codeLabelsBefore.Count == 0))
{
this.mCodeSectionIsChanged = false;
}
else
{
codeLabelsAfter.Sort();
codeLabelsBefore.Sort();
if(Enumerable.SequenceEqual(codeLabelsAfter, codeLabelsBefore))
{
this.mCodeSectionIsChanged = false;
}
else
{
this.mCodeSectionIsChanged = true;
}
}