如果两个列表相同,为什么我会出错?检查下面的代码
♥list1⟦⟧=a❚b❚c❚d
♥list2⟦⟧=a❚b❚c❚d
dialog ♥list1==♥list2
列表不一样,它们只是包含相同的元素。要检查这一点,您需要将每个列表元素相互比较,例如如下所示。
♥list1 = a❚b❚c❚d
♥list2 = a❚b❚c❚d
♥areListsTheSame = true
if ⊂♥list1.Count == ♥list2.Count⊃
♥i = 1
while ⊂♥areListsTheSame && ♥i <= ♥list1.Count⊃
if ⊂♥list1⟦♥i⟧ != ♥list2⟦♥i⟧⊃
♥areListsTheSame = false
end if
♥i = ♥i + 1
end while
else
♥areListsTheSame = false
end if
if ⊂♥areListsTheSame⊃
dialog ‴The lists are the same‴
else
dialog ‴The lists are not the same‴
end if