Custom iterator for dictionary?
- by aaginor
Hi folks,
in my C#-Application, I have a Dictionary object. When iterating over the object using foreach, I naturally get each element of the dictionary. But I want only certain elements to be iterated, depending on the value of a property of MyValue.
class MyValue
{
public bool AmIIncludedInTheIteration { get; set; }
...
}
Whenever AmIIncludedInTheIteration is false, the item shall not be returned by foreach. I understand that I need to implement my own iterator and override the Dictionary-Iterator somewhere. Can anyone here give me a short HowTo?
Thanks in advance,
Frank