我想知道分号后的一个 sourceList 值是否包含在由 Name 属性标识的 targetList 中。如果那是真的,则必须返回布尔值。
它不工作,但我尝试了一些东西......
我想我的 linq 不正确。所有的东西......
“FoundSomething”包含在 targetList 中,因此它应该返回 TRUE。
var sourceList = new String[]
{
"1;HideButton",
"2;ShowButton",
"3;HideButton",
"4;ShowButton",
"5;HideButton",
"6;ShowButton",
"7;HideButton",
"8;ShowButton",
"9;HideButton",
"10;FoundSomething",
};
var targetList = new List<GlobalConfiguration>()
{
new GlobalConfiguration{ Name = "444" },
new GlobalConfiguration{ Name = "fdsdffd" },
new GlobalConfiguration{ Name = "44" },
new GlobalConfiguration{ Name = "fsdd" },
new GlobalConfiguration{ Name = "fs4rtref" },
new GlobalConfiguration{ Name = "ftrtras" },
new GlobalConfiguration{ Name = "FoundSomething" },
};
Boolean exists = sourceList.Any(a => targetList.All(c => c.Name == a.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Last()));