在工作之余,将写代码过程中较好的一些代码段做个记录,如下代码内容是关于C#查找列表中所有重复出现的元素的代码,希望对码农们有一些用途。
public T[] GetDuplicates(T inputValue)
{
List duplicates = new List( );
for (int i = 0; i < this.Count; i++)
{
if (this[i].Equals(inputValue))
{
duplicates.Add(this[i]);
}
}
return (duplicates.ToArray( ));
}
C#查找列表中所有重复出现的元素的代码
最新推荐文章于 2024-05-17 11:15:25 发布