Quote:
quote:Originally posted by Scott Rider
I want to add to the hashtable only when there is NOT a match. How do I apply NOT to the following code?
foreach(Match in Regex.Matches(string)){
if(Hashtable.ContainsValue(Match)){
Hashtable.Add(int++, Match.ToString());
}
}
|
Scott,
It looks to me that you are adding the string representation of Match to the Hashtable yet you are passing the object Match to ContainsValue for comparison. So it is basically comparing an object to a string value. They will never be equal. I am not set up to test this right now, but try this,
foreach(Match in Regex.Matches(string)){
if(!Hashtable.ContainsValue(Match.ToString())){
Hashtable.Add(int++, Match.ToString());
}
}
Let me know if it Works
Bilal