1. 程式人生 > >判斷數組中是否有重復的數據

判斷數組中是否有重復的數據

數組 rep 數據 AI pub sre you value ring

public bool IsRepeat(string[] yourValue)
{
    Hashtable ht = new Hashtable();
    for (int i = 0; i < yourValue.Length - 1; i++)
    {
        if(ht.Contains(yourValue[i]))
        {
            return true;
        }
        else
        {
        ht.Add(yourValue[i], yourValue[i]);
        }
    }
    
return false; }

判斷數組中是否有重復的數據