Код: Выделить всё
public IEnumerable GetValues()
{
var results = new Dictionary();
// ... fill data from data reader
yield return results;
}
Итак... что касается сборки мусора и непрерывности памяти: Имеет ли смысл сделать что-то подобное?
Код: Выделить всё
private Dictionary _resultHolder = new Dictionary();
public IEnumerable GetValues()
{
// Don't want the previous record values, so clear
_resultHolder.Clear();
// ... fill data from data reader
yield return _resultHolder;
}
Будет ли такое объединение объектов в пул преждевременной оптимизацией?
Подробнее здесь: https://stackoverflow.com/questions/604 ... r-better-t