Skip to content

Commit c7f8d15

Browse files
DevonAleshireBillWagner
authored andcommitted
Index Initializer (#5577)
* Update csharp-6 Modified Index Initializer verbiage to identify collection initializers were able to be used with Dictionaries previously. Tried to identify that the change makes use of the indexer versus calling the add method by remaining more consistent with index usage. Might want to update example or links to the Dictionary collection initializer page within docs. * Index Initializer #5506 Update typo and verbiage in accordance with reviewed comments.
1 parent 3c7ff7a commit c7f8d15

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/csharp/whats-new/csharp-6.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,12 @@ if any, is lost.
508508
## Index Initializers
509509

510510
*Index Initializers* is one of two features that make collection
511-
initializers more consistent. In earlier releases of C#, you could use
512-
*collection initializers* only with sequence style collections:
511+
initializers more consistent with index usage. In earlier releases of C#, you could use
512+
*collection initializers* only with sequence style collections, including <xref:System.Collections.Generic.Dictionary%602> by adding braces around key and value pairs:
513513

514514
[!code-csharp[ListInitializer](../../../samples/snippets/csharp/new-in-6/initializers.cs#ListInitializer)]
515515

516-
Now, you can also use them with <xref:System.Collections.Generic.Dictionary%602> collections and similar types:
516+
Now, you can use them with <xref:System.Collections.Generic.Dictionary%602> collections and similar types. The new syntax supports assignment using an index into the collection:
517517

518518
[!code-csharp[DictionaryInitializer](../../../samples/snippets/csharp/new-in-6/initializers.cs#DictionaryInitializer)]
519519

0 commit comments

Comments
 (0)