Remoting IEnumerables

You’re writing this really cool and innovative class to calculate the first hundred thousand natural numbers. You think about the API, and you realize that returning an array of the numbers a) might take a long time to complete, and b) is going to cause memory usage to spike up like mad. So you decide to stream them instead, returning an IEnumerable<T> instance instead of an array. Being a crack C# developer, you use the incredibly powerful yield keyword, rather than rolling your own implementation of the IEnumerable<T> interface. 1: class MyCoolMathEngine 2: { 3: public IEnumerable<int> GetFirstHundredThousandNaturalNumbers() 4: { … Continue reading Remoting IEnumerables