I have a Class that uses a dictionary to store some data.
But I want to hide that implementation detail from the outside, to iterate all my data I would like to send an iterator to the ouside of my class
how can I do this?
public IEnumerable<KeyValuePair<int, string>> Foo()
{
var implementationDetail = new Dictionary<int, string>
{
{ 1, "foo" },
{ 2, "bar" },
};
return implementationDetail;
}
You may call the Dictinary.GetEnumerator()
that returns an enumerator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With