Skip to content

Commit 8370d83

Browse files
WilliamAntonRohmmairaw
authored andcommitted
Try. NET update for system.collections.generic.dictionary-2.* (#2905)
* added Try .NET interactive example decorations * added Try .NET interactive example decorations * Update Dictionary`2.xml
1 parent 2c8edca commit 8370d83

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

xml/System.Collections.Generic/Dictionary`2.xml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
120120
121121
## Examples
122+
123+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
124+
122125
The following code example creates an empty <xref:System.Collections.Generic.Dictionary%602> of strings with string keys and uses the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method to add some elements. The example demonstrates that the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method throws an <xref:System.ArgumentException> when attempting to add a duplicate key.
123126
124127
The example uses the <xref:System.Collections.Generic.Dictionary%602.Item%2A> property (the indexer in C#) to retrieve values, demonstrating that a <xref:System.Collections.Generic.KeyNotFoundException> is thrown when a requested key is not present, and showing that the value associated with a key can be replaced.
@@ -130,7 +133,7 @@
130133
Finally, the example demonstrates the <xref:System.Collections.Generic.Dictionary%602.Remove%2A> method.
131134
132135
[!code-cpp[Generic.Dictionary#1](~/samples/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp#1)]
133-
[!code-csharp[Generic.Dictionary#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#1)]
136+
[!code-csharp-interactive[Generic.Dictionary#1](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#1)]
134137
[!code-vb[Generic.Dictionary#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb#1)]
135138
136139
]]></format>
@@ -201,12 +204,15 @@
201204
202205
203206
## Examples
207+
208+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
209+
204210
The following code example creates an empty <xref:System.Collections.Generic.Dictionary%602> of strings with string keys and uses the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method to add some elements. The example demonstrates that the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method throws an <xref:System.ArgumentException> when attempting to add a duplicate key.
205211
206212
This code example is part of a larger example provided for the <xref:System.Collections.Generic.Dictionary%602> class.
207213
208214
[!code-cpp[Generic.Dictionary#2](~/samples/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp#2)]
209-
[!code-csharp[Generic.Dictionary#2](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#2)]
215+
[!code-csharp-interactive[Generic.Dictionary#2](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#2)]
210216
[!code-vb[Generic.Dictionary#2](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb#2)]
211217
212218
]]></format>
@@ -702,12 +708,15 @@
702708
703709
704710
## Examples
711+
712+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
713+
705714
The following code example creates an empty <xref:System.Collections.Generic.Dictionary%602> of strings with string keys and uses the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method to add some elements. The example demonstrates that the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method throws an <xref:System.ArgumentException> when attempting to add a duplicate key.
706715
707716
This code example is part of a larger example provided for the <xref:System.Collections.Generic.Dictionary%602> class.
708717
709718
[!code-cpp[Generic.Dictionary#2](~/samples/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp#2)]
710-
[!code-csharp[Generic.Dictionary#2](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#2)]
719+
[!code-csharp-interactive[Generic.Dictionary#2](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#2)]
711720
[!code-vb[Generic.Dictionary#2](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb#2)]
712721
713722
]]></format>
@@ -1198,14 +1207,17 @@
11981207
11991208
12001209
## Examples
1210+
1211+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
1212+
12011213
The following code example uses the <xref:System.Collections.Generic.Dictionary%602.Item%2A> property (the indexer in C#) to retrieve values, demonstrating that a <xref:System.Collections.Generic.KeyNotFoundException> is thrown when a requested key is not present, and showing that the value associated with a key can be replaced.
12021214
12031215
The example also shows how to use the <xref:System.Collections.Generic.Dictionary%602.TryGetValue%2A> method as a more efficient way to retrieve values if a program often must try key values that are not in the dictionary.
12041216
12051217
This code example is part of a larger example provided for the <xref:System.Collections.Generic.Dictionary%602> class. `openWith` is the name of the Dictionary used in this example.
12061218
12071219
[!code-cpp[Generic.Dictionary#2](~/samples/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp#2)]
1208-
[!code-csharp[Generic.Dictionary#2](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#2)]
1220+
[!code-csharp-interactive[Generic.Dictionary#2](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#2)]
12091221
[!code-vb[Generic.Dictionary#2](~/samples/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb#2)]
12101222
[!code-cpp[Generic.Dictionary#3](~/samples/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp#3)]
12111223
[!code-csharp[Generic.Dictionary#3](~/samples/snippets/csharp/VS_Snippets_CLR/Generic.Dictionary/CS/source.cs#3)]
@@ -2951,4 +2963,4 @@ Unlike the <xref:System.Collections.Generic.Dictionary%602.Add%2A> method, this
29512963
</Docs>
29522964
</Member>
29532965
</Members>
2954-
</Type>
2966+
</Type>

0 commit comments

Comments
 (0)