- String[] arrstr = new String[] { "1", "2", "3", "2", "3", "4", "5", "6", "1", "7", "8", "2", "3", "4", };
/// <summary>
/// 移除数组中重复的项
/// </summary>
/// <param name="arr"></param>
/// <returns></returns>
private Hashtable RemoveSame(String[] arr)
{
Hashtable ht = new Hashtable();
for (int i = 0; i < arr.Length; i++)
{
if (ht[arr[i].ToString()] == null)
{
ht[arr[i].ToString()] = arr[i];
}
}
return ht;
} - /// <summary>
/// 移除数组中重复的项
/// </summary>
/// <param name="arr"></param>
/// <returns></returns>
private ArrayList RemoveSame(String[] arr)
{
Hashtable ht = new Hashtable(); - ArrayList al=new ArrayList ();
for (int i = 0; i < arr.Length; i++)
{
if (ht[arr[i].ToString()] == null)
{
ht[arr[i].ToString()] = arr[i]; - al.add(arr[i]);
}
}
return al;
}
RemoveSame(arrstr);