【发布时间】:2010-07-13 20:35:22
【问题描述】:
假设我有以下字符串列表:
string[] list1 = { "one", "two", "three", "four"};
string[] list2 = { "one", "two", "three" };
string[] list3 = { "three", "two", "one" };
我需要一个允许我比较 list2 和 list1 的查询,如果 list2 中的所有字符串都存在于 list1 中,则返回 true,与 list2 的顺序相同。
因此,如果我将 list2 与 list1 进行比较,这样的查询将返回 true,因为 list2 中的所有字符串都在 list1 中,与 list2 的顺序相同。
如果我将 list3 与 list1 进行比较,查询将返回 false,因为即使 list3 中的字符串存在于 list1 中,它们的顺序也不相同。
这样的查询可能吗?
【问题讨论】:
-
如果
string[] list1 = { "one", "two", "four", "three"};compare(list1, list2) 仍然是真的? (技术上与您描述的措辞相符)
标签: linq