.net 数组去重
2021-01-18 11:36 石吴玉 阅读(815) 评论(0) 编辑 收藏 举报方式:使用表达式:
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(',');