1、
去重distinct()或者GroupBy(p => p).Select(p => p.Key),去重的对象都需要为数组,具体看代码
string itemfileids = "1,3,3,5,4,6,8,4,7,5,1,2";
string[] sArray = itemfileids.Split(',');
var dd = sArray.GroupBy(p => p).Select(p => p.Key).ToArray();//去重方法一
string array="";
for (int i = 0; i < dd.Length; i++)
{
array += dd[i];
}
2、string[] sArray = commands.Distinct().ToArray();//去重方法二
另外、list去重也同理:list = list.Distinct().ToList(); 即可
标签:sArray,ToArray,string,C#,dd,list,数组,去除 From: https://www.cnblogs.com/castlewu/p/17126412.html