How to tell whether an IEnumerable<T> has already been materialized in C#
There is no HasBeenEnumerated flag on IEnumerable<T>. Here is what TryGetNonEnumeratedCount actually checks, why Enumerable.Range passes an ICollection<T> test, and the guard that avoids a wasted ToList().