方式:使用表达式:
1.对象去重:
users.Where((x,i)=>users.FindIndex(z=>z.name == x.name) == i)
2.List<string> 类型去重:
List<string> worldList = recharge.World_Id.Split(',').ToList(); worldList = worldList.Where((x, i) => worldList.FindIndex(z => z == x) == i).ToList(); recharge.World_Id = string.Join(',', worldList).TrimEnd(',');