How to detect if a LINQ enumeration is materialized?
Posted
by Peter Lillevold
on Stack Overflow
See other posts from Stack Overflow
or by Peter Lillevold
Published on 2010-05-18T13:30:30Z
Indexed on
2010/05/18
13:41 UTC
Read the original article
Hit count: 271
LINQ
|linq-to-objects
Is there some way of detecting whether an enumerable built using LINQ (to Objects in this case) have been materialized or not? Other than trying to inspect the type of the underlying collection?
Specifically, since enumerable.ToArray()
will build a new array even if the underlying collection already is an array I'm looking for a way of avoiding ToArray()
being called twice on the same collection.
© Stack Overflow or respective owner