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.