|
61 | 61 | Although you can create an instance of a tuple class by calling its class constructor, the code to do so can be cumbersome. The following example uses a class constructor to create a 7-tuple or septuple that contains population data for New York City for each census from 1950 through 2000. |
62 | 62 | |
63 | 63 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/example1.cs" interactive="try-dotnet-method" id="Snippet1"::: |
| 64 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/example1.fs" id="Snippet1"::: |
64 | 65 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.class/vb/example1.vb" id="Snippet1"::: |
65 | 66 | |
66 | 67 | Creating the same tuple object by using a helper method is more straightforward, as the following example shows. |
67 | 68 | |
68 | 69 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/example1.cs" interactive="try-dotnet-method" id="Snippet2"::: |
| 70 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/example1.fs" id="Snippet2"::: |
69 | 71 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.class/vb/example1.vb" id="Snippet2"::: |
70 | 72 | |
71 | 73 | The <xref:System.Tuple.Create%2A> helper methods directly support the creation of tuple objects that have from one to eight components (that is, singletons through octuples). Although there is no practical limit to the number of components a tuple may have, helper methods are not available to create a tuple with nine or more components. To create such a tuple, you must call the <xref:System.Tuple%608.%23ctor%2A?displayProperty=nameWithType> constructor. |
|
79 | 81 | The following example creates an 8-tuple (octuple) that contains prime numbers that are less than 20. |
80 | 82 | |
81 | 83 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/createntuple.cs" interactive="try-dotnet-method" id="Snippet17"::: |
| 84 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/createntuple.fs" id="Snippet17"::: |
82 | 85 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/createntuple.vb" id="Snippet17"::: |
83 | 86 | |
84 | 87 | ]]></format> |
|
158 | 161 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 1-tuple object without having to explicitly specify the type of its component. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 1-tuple whose component is of type <xref:System.Int32>. |
159 | 162 | |
160 | 163 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet1"::: |
| 164 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet1"::: |
161 | 165 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet1"::: |
162 | 166 | |
163 | 167 | This code is equivalent to the following call to the <xref:System.Tuple%601.%23ctor%2A> class constructor. |
164 | 168 | |
165 | 169 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet2"::: |
| 170 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet2"::: |
166 | 171 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet2"::: |
167 | 172 | |
168 | 173 | ]]></format> |
|
226 | 231 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 2-tuple object without having to explicitly specify the types of its components. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 2-tuple. |
227 | 232 | |
228 | 233 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet3"::: |
| 234 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet3"::: |
229 | 235 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet3"::: |
230 | 236 | |
231 | 237 | This code is equivalent to the following call to the <xref:System.Tuple%602.%23ctor%2A> class constructor. |
232 | 238 | |
233 | 239 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet4"::: |
| 240 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet4"::: |
234 | 241 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet4"::: |
235 | 242 |
|
236 | 243 | ]]></format> |
|
298 | 305 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 3-tuple object without having to explicitly specify the types of its components. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 3-tuple. |
299 | 306 | |
300 | 307 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet5"::: |
| 308 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet5"::: |
301 | 309 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet5"::: |
302 | 310 | |
303 | 311 | This code is equivalent to the following call to the <xref:System.Tuple%603.%23ctor%2A?displayProperty=nameWithType> class constructor. |
304 | 312 | |
305 | 313 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet6"::: |
| 314 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet6"::: |
306 | 315 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet6"::: |
307 | 316 | |
308 | 317 | ]]></format> |
|
374 | 383 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 4-tuple object without having to explicitly specify the types of its components. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 4-tuple. |
375 | 384 | |
376 | 385 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet7"::: |
| 386 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet7"::: |
377 | 387 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet7"::: |
378 | 388 | |
379 | 389 | This code is equivalent to the following call to the <xref:System.Tuple%604.%23ctor%2A?displayProperty=nameWithType> class constructor. |
380 | 390 | |
381 | 391 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet8"::: |
| 392 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet8"::: |
382 | 393 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet8"::: |
383 | 394 | |
384 | 395 | ]]></format> |
|
454 | 465 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 5-tuple object without having to explicitly specify the types of its components. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 5-tuple. |
455 | 466 | |
456 | 467 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet9"::: |
| 468 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet9"::: |
457 | 469 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet9"::: |
458 | 470 | |
459 | 471 | This code is equivalent to the following call to the <xref:System.Tuple%605.%23ctor%2A> class constructor. |
460 | 472 | |
461 | 473 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet10"::: |
| 474 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet10"::: |
462 | 475 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet10"::: |
463 | 476 | |
464 | 477 | ]]></format> |
|
538 | 551 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 6-tuple object without having to explicitly specify the types of its components. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 6-tuple. |
539 | 552 | |
540 | 553 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet11"::: |
| 554 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet11"::: |
541 | 555 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet11"::: |
542 | 556 | |
543 | 557 | This code is equivalent to the following call to the <xref:System.Tuple%606.%23ctor%2A> class constructor. |
544 | 558 | |
545 | 559 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet12"::: |
| 560 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet12"::: |
546 | 561 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet12"::: |
547 | 562 | |
548 | 563 | ]]></format> |
|
626 | 641 | <xref:System.Tuple.Create%2A> is a helper method that you can call to instantiate a 7-tuple object without having to explicitly specify the types of its components. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 7-tuple. |
627 | 642 | |
628 | 643 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet13"::: |
| 644 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet13"::: |
629 | 645 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet13"::: |
630 | 646 | |
631 | 647 | This code is equivalent to the following call to the <xref:System.Tuple%607.%23ctor%2A> class constructor. |
632 | 648 | |
633 | 649 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" interactive="try-dotnet-method" id="Snippet14"::: |
| 650 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet14"::: |
634 | 651 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet14"::: |
635 | 652 | |
636 | 653 | ]]></format> |
|
726 | 743 | The following example creates an 8-tuple whose components are prime numbers that are less than 20. |
727 | 744 | |
728 | 745 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/createntuple.cs" interactive="try-dotnet-method" id="Snippet17"::: |
| 746 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/createntuple.fs" id="Snippet17"::: |
729 | 747 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/createntuple.vb" id="Snippet17"::: |
730 | 748 |
|
731 | 749 | This is equivalent to the following example, which uses the <xref:System.Tuple%608> class constructor instead of the <xref:System.Tuple.Create%2A> factory creation method. Note that instantiating a <xref:System.Tuple%608> object in this way involves considerably more code, because you must declare a nested <xref:System.Tuple%601> object as the <xref:System.Tuple%608> object's eighth component to produce an octuple. |
732 | 750 | |
733 | 751 | :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/ctor8.cs" id="Snippet20"::: |
| 752 | + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/ctor8.fs" id="Snippet20"::: |
734 | 753 | :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/ctor8.vb" id="Snippet20"::: |
735 | 754 | |
736 | 755 | ]]></format> |
|
0 commit comments