先引用:using System.Linq;//www.uzhanbao.com
#region 移除数组中重复数据
/// <summary>
/// 移除数组中重复数据
/// </summary>
/// <param name="array">需要除重的数组</param>
/// <returns>不重复数组</returns>
public static string[] DelRepeatData(string[] array)
{
return array.GroupBy(p => p).Select(p => p.Key).ToArray();
}
#endregion
list去除重复
string[] stringArray = { "aaa", "bbb", "aaa", "ccc", "bbb", "ddd", "ccc", "aaa", "bbb", "ddd" };
//List用于存储从数组里取出来的不相同的元素
List<string> listString = new List<string>();
foreach (string eachString in stringArray)
{
if (!listString.Contains(eachString))
listString.Add(eachString);
}