List<T>去重
static void Main(string[] args)
{
List<int> users = new List<int>()
{
1,2,3,4,5,1,2,3,4,5
};
var count = users.Count;
users = new HashSet<int>(users).ToList();
var count2 = users.Count;
Console.WriteLine($"去重前:{count} 去重后:{count2}");
}
去重前:10 去重后:5
本文来自博客园,作者:三石PY,转载请注明原文链接:https://www.cnblogs.com/sanshi01/p/18678606

浙公网安备 33010602011771号