Я использую HashSet для того, чтобы в моей коллекции не было двух (или более) элементов с одинаковым значением, в моей работе мне нужно перебрать мой хэш-набор и удалить его значения, но, к сожалению, я не могу этого сделать, что я пытаюсь сделать это:
string newValue = "";
HashSet<string> myHashSet;
myHashSet = GetAllValues(); // lets say there is a function which fill the hashset
foreach (string s in myHashSet)
{
newValue = func(s) // lets say that func on some cases returns s as it was and
if(s != newValue) // for some cases returns another va
{
myHashSet.Remove(s);
myHashSet.Add(newValue);
}
}
заранее спасибо за вашу помощь