|
268 | 268 |
|
269 | 269 | If <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.MoveNext%2A> passes the end of the collection, the enumerator is positioned after the last element in the collection and <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.MoveNext%2A> returns `false`. When the enumerator is at this position, subsequent calls to <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.MoveNext%2A> also return `false`. If the last call to <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.MoveNext%2A> returned `false`, <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.Current%2A> is undefined. You cannot set <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.Current%2A> to the first element of the collection again; you must create a new enumerator instance instead.
|
270 | 270 |
|
271 |
| - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.MoveNext%2A> or <xref:System.Collections.Generic.Dictionary%602.KeyCollection.Enumerator.System%23Collections%23IEnumerator%23Reset%2A> throws an <xref:System.InvalidOperationException>. |
272 |
| - |
| 271 | + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to <xref:System.Collections.Generic.Dictionary%602.Enumerator.MoveNext%2A> or <xref:System.Collections.Generic.Dictionary%602.Enumerator.System%23Collections%23IEnumerator%23Reset%2A> throws an <xref:System.InvalidOperationException>. |
| 272 | +
|
| 273 | +.NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are <xref:System.Collections.Generic.Dictionary%602.Remove%2A> and <xref:System.Collections.Generic.Dictionary%602.Clear%2A>. |
| 274 | + |
273 | 275 | The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.
|
274 | 276 |
|
275 | 277 | Default implementations of collections in <xref:System.Collections.Generic?displayProperty=nameWithType> are not synchronized.
|
|
569 | 571 |
|
570 | 572 | If <xref:System.Collections.IEnumerator.MoveNext%2A> passes the end of the collection, the enumerator is positioned after the last element in the collection and <xref:System.Collections.IEnumerator.MoveNext%2A> returns `false`. When the enumerator is at this position, subsequent calls to <xref:System.Collections.IEnumerator.MoveNext%2A> also return `false`. If the last call to <xref:System.Collections.IEnumerator.MoveNext%2A> returned `false`, <xref:System.Collections.Generic.IEnumerator%601.Current%2A> is undefined. You cannot set <xref:System.Collections.Generic.IEnumerator%601.Current%2A> to the first element of the collection again; you must create a new enumerator instance instead.
|
571 | 573 |
|
572 |
| - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to <xref:System.Collections.IEnumerator.MoveNext%2A> or <xref:System.Collections.IEnumerator.Reset%2A> throws an <xref:System.InvalidOperationException>. |
| 574 | + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to <xref:System.Collections.Generic.Dictionary%602.Enumerator.MoveNext%2A> or <xref:System.Collections.Generic.Dictionary%602.Enumerator.System%23Collections%23IEnumerator%23Reset%2A> throws an <xref:System.InvalidOperationException>. |
| 575 | +
|
| 576 | +.NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are <xref:System.Collections.Generic.Dictionary%602.Remove%2A> and <xref:System.Collections.Generic.Dictionary%602.Clear%2A>. |
573 | 577 |
|
574 | 578 | The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.
|
575 | 579 |
|
@@ -833,7 +837,9 @@ finally {
|
833 | 837 |
|
834 | 838 | If <xref:System.Collections.IEnumerator.MoveNext%2A> passes the end of the collection, the enumerator is positioned after the last element in the collection and <xref:System.Collections.IEnumerator.MoveNext%2A> returns `false`. When the enumerator is at this position, subsequent calls to <xref:System.Collections.IEnumerator.MoveNext%2A> also return `false`. If the last call to <xref:System.Collections.IEnumerator.MoveNext%2A> returned `false`, <xref:System.Collections.IEnumerator.Current%2A> is undefined. To set <xref:System.Collections.IEnumerator.Current%2A> to the first element of the collection again, you can call <xref:System.Collections.IEnumerator.Reset%2A> followed by <xref:System.Collections.IEnumerator.MoveNext%2A>.
|
835 | 839 |
|
836 |
| - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to <xref:System.Collections.IEnumerator.MoveNext%2A> or <xref:System.Collections.IEnumerator.Reset%2A> throws an <xref:System.InvalidOperationException>. |
| 840 | + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to <xref:System.Collections.Generic.Dictionary%602.Enumerator.MoveNext%2A> or <xref:System.Collections.Generic.Dictionary%602.Enumerator.System%23Collections%23IEnumerator%23Reset%2A> throws an <xref:System.InvalidOperationException>. |
| 841 | +
|
| 842 | +.NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are <xref:System.Collections.Generic.Dictionary%602.Remove%2A> and <xref:System.Collections.Generic.Dictionary%602.Clear%2A>. |
837 | 843 |
|
838 | 844 | The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.
|
839 | 845 |
|
|
0 commit comments