|
125 | 125 | ## Examples
|
126 | 126 | The following example demonstrates how to merge two disparate sets. This example creates two <xref:System.Collections.Generic.HashSet%601> objects, and populates them with even and odd numbers, respectively. A third <xref:System.Collections.Generic.HashSet%601> object is created from the set that contains the even numbers. The example then calls the <xref:System.Collections.Generic.HashSet%601.UnionWith%2A> method, which adds the odd number set to the third set.
|
127 | 127 |
|
128 |
| - [!code-csharp[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
| 128 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
129 | 129 | [!code-vb[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/vb/Program.vb#01)]
|
130 | 130 |
|
131 | 131 | ]]></format>
|
|
188 | 188 | The following example demonstrates how to create and populate two <xref:System.Collections.Generic.HashSet%601> objects. This example is part of a larger example provided for the <xref:System.Collections.Generic.HashSet%601.UnionWith%2A> method.
|
189 | 189 |
|
190 | 190 | [!code-csharp[System.Collections.Generic.HashSet_UnionWith#03](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#03)]
|
| 191 | + [!code-vb[System.Collections.Generic.HashSet_UnionWith#03](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/vb/Program.vb#03)] |
191 | 192 |
|
192 | 193 | ]]></format>
|
193 | 194 | </remarks>
|
|
241 | 242 | ## Examples
|
242 | 243 | The following example shows how to create a <xref:System.Collections.Generic.HashSet%601> collection from an existing set. In this example, two sets are created with even and odd integers, respectively. A third <xref:System.Collections.Generic.HashSet%601> object is then created from the even integer set.
|
243 | 244 |
|
244 |
| - [!code-csharp[System.Collections.Generic.HashSet_UnionWith#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#02)] |
| 245 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
245 | 246 | [!code-vb[System.Collections.Generic.HashSet_UnionWith#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/vb/Program.vb#02)]
|
246 | 247 |
|
247 | 248 | ]]></format>
|
|
384 | 385 | The following example uses a supplied <xref:System.Collections.Generic.IEqualityComparer%601> to allow case-insensitive comparisons on the elements of a <xref:System.Collections.Generic.HashSet%601> collection of vehicle types.
|
385 | 386 |
|
386 | 387 | [!code-cpp[System.Collections.Generic.HashSet_ExceptWith#03](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp#03)]
|
387 |
| - [!code-csharp[System.Collections.Generic.HashSet_ExceptWith#03](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cs/source2.cs#03)] |
| 388 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_ExceptWith#03](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cs/source2.cs#03)] |
388 | 389 | [!code-vb[System.Collections.Generic.HashSet_ExceptWith#03](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/vb/source2.vb#03)]
|
389 | 390 |
|
390 | 391 | ]]></format>
|
|
598 | 599 | ## Examples
|
599 | 600 | The following example creates and populates a <xref:System.Collections.Generic.HashSet%601> collection, then clears it and releases the memory referenced by the collection.
|
600 | 601 |
|
601 |
| - [!code-csharp[System.Collections.Generic.HashSet_Clear#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/cs/Program.cs#02)] |
602 |
| - [!code-vb[System.Collections.Generic.HashSet_Clear#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/vb/Program.vb#02)] |
| 602 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_Clear#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/cs/Program.cs#01)] |
| 603 | + [!code-vb[System.Collections.Generic.HashSet_Clear#01](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/vb/Program.vb#01)] |
603 | 604 |
|
604 | 605 | ]]></format>
|
605 | 606 | </remarks>
|
|
705 | 706 | ## Examples
|
706 | 707 | The following example demonstrates how to remove values from a <xref:System.Collections.Generic.HashSet%601> collection using the <xref:System.Collections.Generic.HashSet%601.Remove%2A> method. In this example, the <xref:System.Collections.Generic.HashSet%601.Contains%2A> method verifies that the set contains a value before removing it.
|
707 | 708 |
|
708 |
| - [!code-csharp[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/cs/Program.cs#02)] |
| 709 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/cs/Program.cs#02)] |
709 | 710 | [!code-vb[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/vb/Program.vb#02)]
|
710 | 711 |
|
711 | 712 | ]]></format>
|
|
949 | 950 | ## Examples
|
950 | 951 | The following example demonstrates how to create, populate, and manipulate two <xref:System.Collections.Generic.HashSet%601> objects. In this example, both the contents of the set and <xref:System.Collections.Generic.HashSet%601.Count%2A> display to the console.
|
951 | 952 |
|
952 |
| - [!code-csharp[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
| 953 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
953 | 954 | [!code-vb[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/vb/Program.vb#01)]
|
954 | 955 |
|
955 | 956 | ]]></format>
|
|
1091 | 1092 | The following example creates two <xref:System.Collections.Generic.HashSet%601> collections with overlapping sets of data. The lower range of values is then removed from the larger set using the <xref:System.Collections.Generic.HashSet%601.ExceptWith%2A> method.
|
1092 | 1093 |
|
1093 | 1094 | [!code-cpp[System.Collections.Generic.HashSet_ExceptWith#02](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp#02)]
|
1094 |
| - [!code-csharp[System.Collections.Generic.HashSet_ExceptWith#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cs/Program.cs#02)] |
| 1095 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_ExceptWith#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cs/Program.cs#02)] |
1095 | 1096 | [!code-vb[System.Collections.Generic.HashSet_ExceptWith#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/vb/Program.vb#02)]
|
1096 | 1097 |
|
1097 | 1098 | ]]></format>
|
|
1340 | 1341 | ## Examples
|
1341 | 1342 | The following example creates two disparate <xref:System.Collections.Generic.HashSet%601> objects and compares them to each other. In this example, `lowNumbers` is both a subset and a proper subset of `allNumbers` until `allNumbers` is modified, using the <xref:System.Collections.Generic.HashSet%601.IntersectWith%2A> method, to contain only values that are present in both sets. Once `allNumbers` and `lowNumbers` are identical, `lowNumbers` is still a subset of `allNumbers` but is no longer a proper subset.
|
1342 | 1343 |
|
1343 |
| - [!code-csharp[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
| 1344 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
1344 | 1345 | [!code-vb[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/vb/Program.vb#02)]
|
1345 | 1346 |
|
1346 | 1347 | ]]></format>
|
|
1413 | 1414 | ## Examples
|
1414 | 1415 | The following example creates two disparate <xref:System.Collections.Generic.HashSet%601> objects and compares them to each other. In this example, `allNumbers` is both a superset and a proper superset of `lowNumbers` until `allNumbers` is modified, using the <xref:System.Collections.Generic.HashSet%601.IntersectWith%2A> method, to contain only values that are present in both sets. Once `allNumbers` and `lowNumbers` are identical, `allNumbers` is still a superset of `lowNumbers` but is no longer a proper superset.
|
1415 | 1416 |
|
1416 |
| - [!code-csharp[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
| 1417 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
1417 | 1418 | [!code-vb[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/vb/Program.vb#02)]
|
1418 | 1419 |
|
1419 | 1420 | ]]></format>
|
|
1486 | 1487 | ## Examples
|
1487 | 1488 | The following example creates two disparate <xref:System.Collections.Generic.HashSet%601> objects and compares them to each other. In this example, `lowNumbers` is both a subset and a proper subset of `allNumbers` until `allNumbers` is modified, using the <xref:System.Collections.Generic.HashSet%601.IntersectWith%2A> method, to contain only values that are present in both sets. Once `allNumbers` and `lowNumbers` are identical, `lowNumbers` is still a subset of `allNumbers` but is no longer a proper subset.
|
1488 | 1489 |
|
1489 |
| - [!code-csharp[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
| 1490 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
1490 | 1491 | [!code-vb[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/vb/Program.vb#02)]
|
1491 | 1492 |
|
1492 | 1493 | ]]></format>
|
|
1554 | 1555 | ## Examples
|
1555 | 1556 | The following example creates two disparate <xref:System.Collections.Generic.HashSet%601> objects and compares them to each other. In this example, `allNumbers` is both a superset and a proper superset of `lowNumbers` until `allNumbers` is modified, using the <xref:System.Collections.Generic.HashSet%601.IntersectWith%2A> method, to contain only values that are present in both sets. Once `allNumbers` and `lowNumbers` are identical, `allNumbers` is still a superset of `lowNumbers` but is no longer a proper superset.
|
1556 | 1557 |
|
1557 |
| - [!code-csharp[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
| 1558 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
1558 | 1559 | [!code-vb[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/vb/Program.vb#02)]
|
1559 | 1560 |
|
1560 | 1561 | ]]></format>
|
|
1666 | 1667 | ## Examples
|
1667 | 1668 | The following example creates two disparate <xref:System.Collections.Generic.HashSet%601> objects and compares them to each another. In this example, `allNumbers` and `lowNumbers` are shown to share common elements using the <xref:System.Collections.Generic.HashSet%601.Overlaps%2A> method.
|
1668 | 1669 |
|
1669 |
| - [!code-csharp[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
| 1670 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
1670 | 1671 | [!code-vb[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/vb/Program.vb#02)]
|
1671 | 1672 |
|
1672 | 1673 | ]]></format>
|
|
1729 | 1730 | ## Examples
|
1730 | 1731 | The following example demonstrates how to remove values from a <xref:System.Collections.Generic.HashSet%601> collection using the <xref:System.Collections.Generic.HashSet%601.Remove%2A> method. In this example, zero is arbitrarily removed from the <xref:System.Collections.Generic.HashSet%601> collection.
|
1731 | 1732 |
|
1732 |
| - [!code-csharp[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/cs/Program.cs#02)] |
| 1733 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/cs/Program.cs#02)] |
1733 | 1734 | [!code-vb[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/vb/Program.vb#02)]
|
1734 | 1735 |
|
1735 | 1736 | ]]></format>
|
|
1784 | 1785 | ## Examples
|
1785 | 1786 | The following example demonstrates how to remove values from a <xref:System.Collections.Generic.HashSet%601> collection using the <xref:System.Collections.Generic.HashSet%601.Remove%2A> method. In this example, all odd integers are removed from the <xref:System.Collections.Generic.HashSet%601> collection as specified by the `match` delegate.
|
1786 | 1787 |
|
1787 |
| - [!code-csharp[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/cs/Program.cs#02)] |
| 1788 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/cs/Program.cs#02)] |
1788 | 1789 | [!code-vb[System.Collections.Generic.HashSet_RemoveWhere#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_RemoveWhere/vb/Program.vb#02)]
|
1789 | 1790 |
|
1790 | 1791 | ]]></format>
|
|
1855 | 1856 | ## Examples
|
1856 | 1857 | The following example creates two disparate <xref:System.Collections.Generic.HashSet%601> objects and compares them to each another. Initially, the two sets are not equal, which is demonstrated by using the <xref:System.Collections.Generic.HashSet%601.SetEquals%2A> method. The `allNumbers`<xref:System.Collections.Generic.HashSet%601> object is then modified, after which the sets are equal.
|
1857 | 1858 |
|
1858 |
| - [!code-csharp[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
| 1859 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/cs/Program.cs#02)] |
1859 | 1860 | [!code-vb[System.Collections.Generic.HashSet_boolMethods#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_boolMethods/vb/Program.vb#02)]
|
1860 | 1861 |
|
1861 | 1862 | ]]></format>
|
|
1922 | 1923 | ## Examples
|
1923 | 1924 | The following example creates two <xref:System.Collections.Generic.HashSet%601> collections with overlapping sets of data. The set that contains the lower values is then modified, using the <xref:System.Collections.Generic.HashSet%601.SymmetricExceptWith%2A> method, to contain only the values that are not present in both sets.
|
1924 | 1925 |
|
1925 |
| - [!code-csharp[System.Collections.Generic.HashSet_SymmetricExceptWith#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_SymmetricExceptWith/cs/Program.cs#02)] |
| 1926 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_SymmetricExceptWith#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_SymmetricExceptWith/cs/Program.cs#02)] |
1926 | 1927 | [!code-vb[System.Collections.Generic.HashSet_SymmetricExceptWith#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_SymmetricExceptWith/vb/Program.vb#02)]
|
1927 | 1928 |
|
1928 | 1929 | ]]></format>
|
|
2199 | 2200 | ## Examples
|
2200 | 2201 | The following example creates and populates a <xref:System.Collections.Generic.HashSet%601> collection, and then clears the collection and releases the memory referenced by it.
|
2201 | 2202 |
|
2202 |
| - [!code-csharp[System.Collections.Generic.HashSet_Clear#02](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/cs/Program.cs#02)] |
2203 |
| - [!code-vb[System.Collections.Generic.HashSet_Clear#02](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/vb/Program.vb#02)] |
| 2203 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_Clear#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/cs/Program.cs#01)] |
| 2204 | + [!code-vb[System.Collections.Generic.HashSet_Clear#01](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_Clear/vb/Program.vb#01)] |
2204 | 2205 |
|
2205 | 2206 | ]]></format>
|
2206 | 2207 | </remarks>
|
|
2303 | 2304 | ## Examples
|
2304 | 2305 | The following example demonstrates how to merge two disparate sets. This example creates two <xref:System.Collections.Generic.HashSet%601> objects, and populates them with even and odd numbers, respectively. A third <xref:System.Collections.Generic.HashSet%601> object is created from the set that contains the even numbers. The example then calls the <xref:System.Collections.Generic.HashSet%601.UnionWith%2A> method, which adds the odd number set to the third set.
|
2305 | 2306 |
|
2306 |
| - [!code-csharp[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
| 2307 | + [!code-csharp-interactive[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/cs/Program.cs#01)] |
2307 | 2308 | [!code-vb[System.Collections.Generic.HashSet_UnionWith#01](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_UnionWith/vb/Program.vb#01)]
|
2308 | 2309 |
|
2309 | 2310 | ]]></format>
|
|
0 commit comments