I’m newb with generics/iterators/enumerators etc.
I have code, it keeps field number (int) and error mesages (List string) for each field:
public class ErrorList : IEnumerable // ?
{
private Dictionary <int, List<string>> errorList;
// ...
}
How to make this class work with foreach loop? I wanna use GetEnumerator form Dictionary, but how should i do this?
You could simply provide a public
GetEnumeratormethod:and now assuming you have an instance of ErrorList:
you can loop through them: