How does a List know that you changed it while enumerating it?
Read OriginalThis technical article explores the internal mechanism in C# .NET's List<T> that triggers an InvalidOperationException when a list is modified while being enumerated. It demonstrates the concept by building a custom list class and shows how a 'version' field is incremented on mutations and checked during iteration to detect changes.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser