not a good way but kind of quick fix, take a bool to check if in whole list there is any duplicate entry.
bool containsKey;
string newKey;
public void addKey(string newKey)
{
foreach (string key in MyKeys)
{
if (key == newKey)
{
containsKey = true;
}
}
if (!containsKey)
{
MyKeys.add(newKey);
}
else
{
containsKey = false;
}
}