J
JohnS
Hi there,
Can someone confirm my understanding of the following. Given a function that
creates and populates a "List<T>" on-the-fly, or any native .NET collection
for that matter, and then returns "List<T>.GetEnumerator()", will that
enumerator keep the list itself alive? Or can the list be GC'd and the
enumerator then points to junk. Presumably this won't happen since the
enumerator will either keep it alive via some internal pointer, or it will
cache the data itself in theory (ok, not likely in reality but the idea is
that it can always enumerate the data even it doesn't keep the collection
alive). Can someone confirm this. Thanks.
Can someone confirm my understanding of the following. Given a function that
creates and populates a "List<T>" on-the-fly, or any native .NET collection
for that matter, and then returns "List<T>.GetEnumerator()", will that
enumerator keep the list itself alive? Or can the list be GC'd and the
enumerator then points to junk. Presumably this won't happen since the
enumerator will either keep it alive via some internal pointer, or it will
cache the data itself in theory (ok, not likely in reality but the idea is
that it can always enumerate the data even it doesn't keep the collection
alive). Can someone confirm this. Thanks.