Итак, у меня есть класс и общий список внутри него, но он закрыт.
class Contacts
{
List<Contact> contacts;
...
}
Я хочу, чтобы класс работал так:
foreach(Contact in contacts) .... ;
как это (не работает):
Contacts c;
foreach(Contact in c) .... ;
В приведенном выше примере экземпляр класса Contact c должен возвращать каждый элемент из контактов (частный член c)
Как мне это сделать? Я знаю, что это должно быть IEnumerable с возвратом доходности, но где объявить это?