【发布时间】:2014-01-25 20:49:04
【问题描述】:
编辑,只是说 ContainsAllItem 中的注释解释得最好。
对不起,我知道以前有人问过这个问题,但我只是没听懂。 好的,所以我想检查一个列表是否包含另一个列表中的所有项目 WITHOUT 重叠,以及根据类字符串、名称变量(称为 itemname 并且它是公共的)比较项目。
public class Item
{
public string itemname;
}
所以基本上,有一个带有项目列表的类(比如说.. A 类),以及一个检查 A 类项目列表的函数,然后将其与另一个列表进行比较(我们称之为 B) ,但通过 itemname 变量而不是整个项目进行比较。
最重要的是,您能否详细解释一下它的作用。
那么函数/类现在的样子。
public class SomeClass
{
public List<Item> myItems = new List<Item>();
public bool ContainsAllItems(List<Item> B)
{
//Make a function that compares the to lists by itemname and only returns true if the myItems list contains ALL, items in list b.
//Also could you explain how it works.
}
}
【问题讨论】:
-
而 不重叠 你的意思是列表应该相等?