System.Interactive: Difference between Memoize() and MemoizeAll()?

Posted by Joel Mueller on Stack Overflow See other posts from Stack Overflow or by Joel Mueller
Published on 2010-05-28T18:32:47Z Indexed on 2010/05/28 19:02 UTC
Read the original article Hit count: 271

In System.Interactive.dll (v1.0.2521.0) from Reactive Extensions, EnumerableEx has both a Memoize method and a MemoizeAll method. The API documentation is identical for both of them:

Creates an enumerable that enumerates the original enumerable only once and caches its results.

However, these methods are clearly not identical. If I use Memoize, my enumerable has values the first time I enumerate it, and seems to be empty the second time. If I use MemoizeAll then I get the behavior I would expect from the description of either method - I can enumerate the result as many times as I want and get the same results each time, but the source is only enumerated once.

Can anyone tell me what the intended difference between these methods is? What is the use-case for Memoize? It seems like a fairly useless method with really confusing documentation.

© Stack Overflow or respective owner

Related posts about c#

Related posts about system.reactive