I have a list of objects, each with 2 relevant properties: "ID" and "Name". Lets call the list "lstOutcomes".
I need to check the list for duplicates (meaning object1.ID = object2.ID
, etc.) and set a flag (valid = false
, or something) if there is at least one duplicate. Also, it would be nice to send a message to the user mentioning the "Name" of the object, when it fails.
我相信,我需要使用<代码>。 专家组通过代码>进行这项工作,但我没有在准则和准则中这样做,所列举的例子仅仅无助于我。 第条似乎接近于需要,但并非完全需要,而是载于C#。
......
Dim duplist = _
(From o As objectType In lstOutcomes _
Group o By o.ID Into g = Group _
Let dups = g.Where(Function(h) g.Count > 1) _
Order By dups Descending).ToArray
if duplist.count > 0 then
valid = false
end if
帮助?