public List<int> CheckHash(List<int> data)
{
Hashtable hasttable = new Hashtable();
}
检查 data数组中的重复数 最后输出所有重复数及个数 按照先后顺序
如3 1 5 3 3 1
输出 3 3 3 1 1
{
Hashtable hasttable = new Hashtable();
}
检查 data数组中的重复数 最后输出所有重复数及个数 按照先后顺序
如3 1 5 3 3 1
输出 3 3 3 1 1
{
return (from x in data group x by x into g select g).Where(g => g.Count() > 1).SelectMany(x => x).ToList();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(string.Join(" ", CheckHash(new List<int>() { 3, 1, 5, 3, 3, 1 })));
}
static List<int> CheckHash(List<int> data)
{
return (from x in data group x by x into g select g).Where(g => g.Count() > 1).SelectMany(x => x).ToList();
}
}
}3 3 3 1 1
Press any key to continue . . .
Hashtable hasttable = new Hashtable();
用hasttable的属性方法 写一次 我好能在msdn中更好的了解 谢谢了