根据对象中的属性查找重复项

编程入门 行业动态 更新时间:2024-10-19 09:36:06
本文介绍了根据对象中的属性查找重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想根据对象中的字段检查重复项.

I want to check for duplicates based on a field in an object.

我有一个名为Item的对象,该对象具有3个属性

I have an object called Item that has 3 properties

ID Rank Name

我在一个名为

lstTheItems

我正在使用此代码检查重复项

I am using this code to check for duplicates

'lstTheItems IS NOT CORRECT Dim duplicates = lstTheItems.GroupBy(Function(i) i) _ .Where(Function(g) g.Count() > 1) _ .[Select](Function(g) g.Key)

如何基于Name属性返回重复项?

How do I return duplicate items base on the Name property?

推荐答案

Dim duplicates = svgGrpContainer.Select(Function(x) svgGrpContainer.Count(Function(y)) > 1));

这意味着我们将选择svgGrpContainer中出现多次的所有元素.

This means that we will select all the elements which appear more than once in the svgGrpContainer.

Function(x) = svgGrpContainer的一个元素

Function(x) = one element of svgGrpContainer

svgGrpContainer.Count =遍历所有获得计数的元素.

svgGrpContainer.Count = go through all the elements getting the count of..

Function(y) > 1 =表示我们将所有出现一次以上的所有元素

Function(y) > 1 = means that we will take all the element which appear more than once

我希望这对您有帮助

更多推荐

根据对象中的属性查找重复项

本文发布于:2023-11-07 06:06:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565736.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:象中   属性

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!