diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals1.fs new file mode 100644 index 00000000000..5f35e5ae99f --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals1.fs @@ -0,0 +1,40 @@ +module equals1 + +// +open System + +let temperatureInfos = + [| Tuple.Create(2, 97.9, 97.8, 98.0, 98.2) + Tuple.Create(1, 98.6, 98.8, 98.8, 99.0) + Tuple.Create(2, 98.6, 98.6, 98.6, 98.4) + Tuple.Create(1, 98.4, 98.6, 99.0, 99.2) + Tuple.Create(2, 98.6, 98.6, 98.6, 98.4) + Tuple.Create(1, 98.6, 98.8, 98.8, 99.0) |] +// Compare each item with every other item for equality. +for ctr = 0 to temperatureInfos.Length - 1 do + let temperatureInfo = temperatureInfos[ctr] + for ctr2 = ctr + 1 to temperatureInfos.Length - 1 do + printfn $"{temperatureInfo} = {temperatureInfos[ctr2]}: {temperatureInfo.Equals temperatureInfos[ctr2]}" + printfn "" + +// The example displays the following output: +// (2, 97.9, 97.8, 98, 98.2) = (1, 98.6, 98.8, 98.8, 99): False +// (2, 97.9, 97.8, 98, 98.2) = (2, 98.6, 98.6, 98.6, 98.4): False +// (2, 97.9, 97.8, 98, 98.2) = (1, 98.4, 98.6, 99, 99.2): False +// (2, 97.9, 97.8, 98, 98.2) = (2, 98.6, 98.6, 98.6, 98.4): False +// (2, 97.9, 97.8, 98, 98.2) = (1, 98.6, 98.8, 98.8, 99): False +// +// (1, 98.6, 98.8, 98.8, 99) = (2, 98.6, 98.6, 98.6, 98.4): False +// (1, 98.6, 98.8, 98.8, 99) = (1, 98.4, 98.6, 99, 99.2): False +// (1, 98.6, 98.8, 98.8, 99) = (2, 98.6, 98.6, 98.6, 98.4): False +// (1, 98.6, 98.8, 98.8, 99) = (1, 98.6, 98.8, 98.8, 99): True +// +// (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.4, 98.6, 99, 99.2): False +// (2, 98.6, 98.6, 98.6, 98.4) = (2, 98.6, 98.6, 98.6, 98.4): True +// (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.6, 98.8, 98.8, 99): False +// +// (1, 98.4, 98.6, 99, 99.2) = (2, 98.6, 98.6, 98.6, 98.4): False +// (1, 98.4, 98.6, 99, 99.2) = (1, 98.6, 98.8, 98.8, 99): False +// +// (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.6, 98.8, 98.8, 99): False +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals2.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals2.fs new file mode 100644 index 00000000000..4a157efaf8f --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals2.fs @@ -0,0 +1,40 @@ +module equals2 + +// +open System +open System.Collections + +type DoubleComparer<'T1, 'T2, 'T3, 'T4, 'T5 when 'T1: equality and 'T2: equality and 'T3: equality and 'T4: equality and 'T5: equality>(difference: double) = + let mutable argument = 0 + + interface IEqualityComparer with + member _.Equals(x, y) = + argument <- argument + 1 + + // Return true for Item1. + if argument = 1 then + true + else + let d1 = x :?> double + let d2 = y :?> double + + d1 - d2 < d1 * difference + + member _.GetHashCode(obj) = + match obj with + | :? 'T1 as obj -> obj.GetHashCode() + | :? 'T2 as obj -> obj.GetHashCode() + | :? 'T3 as obj -> obj.GetHashCode() + | :? 'T4 as obj -> obj.GetHashCode() + | _ -> (obj :?> 'T5).GetHashCode() + +let getValues ctr = + // Generate four random numbers between 0 and 1 + let rnd = Random(DateTime.Now.Ticks >>> 32 >>> ctr |> int) + Tuple.Create(ctr, rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble()) + +let value1 = getValues 1 +let value2 = getValues 2 +let iValue1 = value1 +printfn $"{value1} =\n{value2} :\n{(DoubleComparer 0.01 :> IEqualityComparer).Equals(iValue1, value2)}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/fs.fsproj new file mode 100644 index 00000000000..dffbaeb281d --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/fs.fsproj new file mode 100644 index 00000000000..2180baba850 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs new file mode 100644 index 00000000000..27e1d160c66 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs @@ -0,0 +1,22 @@ +module item1 + +// +open System + +// Define array of tuples reflecting population change by state, 1990-2000. +let statesData = + [| Tuple.Create("California", 29760021, 33871648, 4111627, 13.8) + Tuple.Create("Illinois", 11430602, 12419293, 988691, 8.6) + Tuple.Create("Washington", 4866692, 5894121, 1027429, 21.1) |] + +// Display the items of each tuple +printfn "%-12s%18s%18s%15s%12s\n" "State" "Population 1990" "Population 2000" "Change" "% Change" +for stateData in statesData do + printfn $"{stateData.Item1,-12}{stateData.Item2,18:N0}{stateData.Item3,18:N0}{stateData.Item4,15:N0}{stateData.Item5,12:P1}" +// The example displays the following output: +// State Population 1990 Population 2000 Change % Change +// +// California 29,760,021 33,871,648 4,111,627 13.8 % +// Illinois 11,430,602 12,419,293 988,691 8.6 % +// Washington 4,866,692 5,894,121 1,027,429 21.1 % +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/example1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/example1.fs new file mode 100644 index 00000000000..096a4607582 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/example1.fs @@ -0,0 +1,52 @@ +// +open System + +let computeStatistics (players: Tuple[]) = + [| for player in players do + // Create result object containing player name and statistics. + Tuple.Create(player.Item1, + double player.Item3 / double player.Item2, + double player.Item4 / double player.Item2, + double player.Item4 / double player.Item3, + double player.Item5 / double player.Item3) |] + + +// Organization of runningBacks 5-tuple: +// Component 1: Player name +// Component 2: Number of games played +// Component 3: Number of attempts (carries) +// Component 4: Number of yards gained +// Component 5: Number of touchdowns +let runningBacks = + [| Tuple.Create("Payton, Walter", 190, 3838, 16726, 110) + Tuple.Create("Sanders, Barry", 153, 3062, 15269, 99) + Tuple.Create("Brown, Jim", 118, 2359, 12312, 106) + Tuple.Create("Dickerson, Eric", 144, 2996, 13259, 90) + Tuple.Create("Faulk, Marshall", 176, 2836, 12279, 100) |] +// Calculate statistics. +// Organization of runningStats 5-tuple: +// Component 1: Player name +// Component 2: Number of attempts per game +// Component 3: Number of yards per game +// Component 4: Number of yards per attempt +// Component 5: Number of touchdowns per attempt +let runningStats = computeStatistics runningBacks + +// Display the result. +printfn "%-16s %5s %6s %7s %7s %7s %7s %5s %7s\n" "Name" "Games" "Att" "Att/Gm" "Yards" "Yds/Gm" "Yds/Att" "TD" "TD/Att" +for i = 0 to runningBacks.Length - 1 do + printfn $"{runningBacks[i].Item1,-16} {runningBacks[i].Item2,5} {runningBacks[i].Item3,6:N0} {runningBacks[i].Item2,7:N1} {runningBacks[i].Item4,7:N0} {runningBacks[i].Item3,7:N1} {runningBacks[i].Item4,7:N2} {runningBacks[i].Item5,5} {runningBacks[i].Item5,7:N3}\n" + +// The example displays the following output: +// Name Games Att Att/Gm Yards Yds/Gm Yds/Att TD TD/Att +// +// Payton, Walter 190 3,838 20.2 16,726 88.0 4.36 110 0.029 +// +// Sanders, Barry 153 3,062 20.0 15,269 99.8 4.99 99 0.032 +// +// Brown, Jim 118 2,359 20.0 12,312 104.3 5.22 106 0.045 +// +// Dickerson, Eric 144 2,996 20.8 13,259 92.1 4.43 90 0.030 +// +// Faulk, Marshall 176 2,836 16.1 12,279 69.8 4.33 100 0.035 +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/fs.fsproj new file mode 100644 index 00000000000..f6fb5493c80 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto1.fs new file mode 100644 index 00000000000..ae2345a4a64 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto1.fs @@ -0,0 +1,46 @@ +module compareto1 + +// +open System + +// Organization of runningBacks 5-tuple: +// Component 1: Player name +// Component 2: Number of games played +// Component 3: Number of attempts (carries) +// Component 4: Number of yards gained +// Component 5: Number of touchdowns +let runningBacks = + [| Tuple.Create("Payton, Walter", 190, 3838, 16726, 110) + Tuple.Create("Sanders, Barry", 153, 3062, 15269, 99) + Tuple.Create("Brown, Jim", 118, 2359, 12312, 106) + Tuple.Create("Dickerson, Eric", 144, 2996, 13259, 90) + Tuple.Create("Faulk, Marshall", 176, 2836, 12279, 100) |] + +// Display the array in unsorted order. +printfn "The values in unsorted order:" +for runningBack in runningBacks do + printfn $"{runningBack}" +printfn "" + +// Sort the array +Array.Sort runningBacks + +// Display the array in sorted order. +printfn "The values in sorted order:" +for runningBack in runningBacks do + printfn $"{runningBack}" +// The example displays the following output: +// The values in unsorted order: +// (Payton, Walter, 190, 3838, 16726, 110) +// (Sanders, Barry, 153, 3062, 15269, 99) +// (Brown, Jim, 118, 2359, 12312, 106) +// (Dickerson, Eric, 144, 2996, 13259, 90) +// (Faulk, Marshall, 176, 2836, 12279, 100) +// +// The values in sorted order: +// (Brown, Jim, 118, 2359, 12312, 106) +// (Dickerson, Eric, 144, 2996, 13259, 90) +// (Faulk, Marshall, 176, 2836, 12279, 100) +// (Payton, Walter, 190, 3838, 16726, 110) +// (Sanders, Barry, 153, 3062, 15269, 99) +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto2.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto2.fs new file mode 100644 index 00000000000..0e57751cf5f --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto2.fs @@ -0,0 +1,57 @@ +module compareto2 + +// +open System +open System.Collections +open System.Collections.Generic + +type YardsGained<'T1, 'T2, 'T3, 'T4, 'T5>() = + interface IComparer with + member _.Compare(x, y) = + match x with + | :? Tuple<'T1, 'T2, 'T3, 'T4, 'T5> as tX -> + let tY = y :?> Tuple<'T1, 'T2, 'T3, 'T4, 'T5> + -1 * Comparer<'T4>.Default.Compare(tX.Item4, tY.Item4) + | _ -> 0 + +// Organization of runningBacks 5-tuple: +// Component 1: Player name +// Component 2: Number of games played +// Component 3: Number of attempts (carries) +// Component 4: Number of yards gained +// Component 5: Number of touchdowns +let runningBacks = + [| Tuple.Create("Payton, Walter", 190, 3838, 16726, 110) + Tuple.Create("Sanders, Barry", 153, 3062, 15269, 99) + Tuple.Create("Brown, Jim", 118, 2359, 12312, 106) + Tuple.Create("Dickerson, Eric", 144, 2996, 13259, 90) + Tuple.Create("Faulk, Marshall", 176, 2836, 12279, 100) |] + +// Display the array in unsorted order. +printfn "The values in unsorted order:" +for runningBack in runningBacks do + printfn $"{runningBack}" +printfn "" + +// Sort the array +Array.Sort(runningBacks, YardsGained()) + +// Display the array in sorted order. +printfn "The values in sorted order:" +for runningBack in runningBacks do + printfn $"{runningBack}" +// The example displays the following output: +// The values in unsorted order: +// (Payton, Walter, 190, 3838, 16726, 110) +// (Sanders, Barry, 153, 3062, 15269, 99) +// (Brown, Jim, 118, 2359, 12312, 106) +// (Dickerson, Eric, 144, 2996, 13259, 90) +// (Faulk, Marshall, 176, 2836, 12279, 100) +// +// The values in sorted order: +// (Brown, Jim, 118, 2359, 12312, 106) +// (Dickerson, Eric, 144, 2996, 13259, 90) +// (Faulk, Marshall, 176, 2836, 12279, 100) +// (Payton, Walter, 190, 3838, 16726, 110) +// (Sanders, Barry, 153, 3062, 15269, 99) +// \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/fs.fsproj new file mode 100644 index 00000000000..d47d675ba4d --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/fs.fsproj b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/fs.fsproj new file mode 100644 index 00000000000..18e3d41d05a --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/tostring1.fs b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/tostring1.fs new file mode 100644 index 00000000000..bf248845d17 --- /dev/null +++ b/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/tostring1.fs @@ -0,0 +1,16 @@ +// +open System + +// Define array of tuples reflecting population change by state, 1990-2000. +let populationChanges = + [| Tuple.Create("California", 29760021, 33871648, 4111627, 13.8) + Tuple.Create("Illinois", 11430602, 12419293, 988691, 8.6) + Tuple.Create("Washington", 4866692, 5894121, 1027429, 21.1) |] +// Display each tuple. +for item in populationChanges do + printfn $"{item.ToString()}" +// The example displays the following output: +// (California, 29760021, 33871648, 4111627, 13.8) +// (Illinois, 11430602, 12419293, 988691, 8.6) +// (Washington, 4866692, 5894121, 1027429, 21.1) +// \ No newline at end of file diff --git a/xml/System/Tuple`5.xml b/xml/System/Tuple`5.xml index 715c09c4823..644b05723ed 100644 --- a/xml/System/Tuple`5.xml +++ b/xml/System/Tuple`5.xml @@ -95,6 +95,7 @@ - To provide easy access to, and manipulation of, a data set. The following example defines an array of objects that contain the names of running backs in American football, the number of games in which they played, and the number of carries, total yards gained, and touchdowns scored during those games. The array is passed to the `ComputeStatistics` method, which calculates each running back's number of carries per game, average yards per game, average yards per carry, and average number of touchdowns per attempt. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Overview/example1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Overview/example1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.class/vb/example1.vb" id="Snippet1"::: - To return multiple values from a method without the use of `out` parameters (in C#) or `ByRef` parameters (in Visual Basic). For example, the previous example returns its computed statistics, along with the name of the player, in an array of objects. @@ -165,11 +166,13 @@ You can also use the static method to instantiate a 5-tuple object without having to explicitly specify the types of its components. The following example uses the method to instantiate a 5-tuple whose first component is of type and its remaining four components are of type . :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" id="Snippet9"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet9"::: This is equivalent to the following call to the class constructor. :::code language="csharp" source="~/snippets/csharp/System/Tuple/Overview/create1.cs" id="Snippet10"::: + :::code language="fsharp" source="~/snippets/fsharp/System/Tuple/Overview/create1.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb" id="Snippet10"::: ]]> @@ -244,6 +247,7 @@ The following example defines an array of 5-tuple objects that contain data about the temperatures of patients in two test groups. The first component of the array provides the number of the test group, and the second through fifth components provide the temperatures of a patient at hourly intervals. The method is called to compare every object with every other object. The output illustrates that the method returns `true` only when all five components of the objects have equal values. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Equals/equals1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.equals/vb/equals1.vb" id="Snippet1"::: ]]> @@ -344,6 +348,7 @@ The following example defines an array of objects whose components contain the name of a state in the United States, its population in 1990 and 2000, its population change in this 10-year period, and the percentage change in its population. It then iterates through the array and displays the value of each component in a tuple. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -403,6 +408,7 @@ The following example defines an array of objects whose components contain the name of a state in the United States, its population in 1990 and 2000, its population change in this 10-year period, and the percentage change in its population. It then iterates through the array and displays the value of each component in a tuple. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -462,6 +468,7 @@ The following example defines an array of objects whose components contain the name of a state in the United States, its population in 1990 and 2000, its population change in this 10-year period, and the percentage change in its population. It then iterates through the array and displays the value of each component in a tuple. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -521,6 +528,7 @@ The following example defines an array of objects whose components contain the name of a state in the United States, its population in 1990 and 2000, its population change in this 10-year period, and the percentage change in its population. It then iterates through the array and displays the value of each component in a tuple. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -580,6 +588,7 @@ The following example defines an array of objects whose components contain the name of a state in the United Dates, its population in 1990 and 2000, its population change in this 10-year period, and the percentage change in its population. It then iterates through the array and displays the value of each component in a tuple. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Item1/item1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.item1/vb/item1.vb" id="Snippet1"::: ]]> @@ -665,6 +674,7 @@ The following example creates an array of objects that contain career statistical data for running backs in American professional football. The 5-tuple's components consist of the player's name, the number of games in which he played, the number of carries or attempts, the total number of yards gained, and the number of touchdowns scored. The example displays the components of each tuple in the array in unsorted order, sorts the array, and then calls to display each tuple in sorted order. To sort the array, the example defines a generic `YardsGained` class that implements the interface and sorts the objects in descending order by the value of their fourth component (yards gained) rather than by their first component. Note that the example does not directly call the method. This method is called implicitly by the method for each element in the array. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto2.cs" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.compareto/vb/compareto2.vb" id="Snippet2"::: ]]> @@ -741,6 +751,7 @@ The following example defines a `DoubleComparer` class that implements the interface. The example instantiates two objects by using a random number generator to populate their second through fifth components, casts the first instance to an interface, and then uses a `DoubleComparer` object to test the two objects for approximate equality. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/Equals/equals2.cs" interactive="try-dotnet" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/Equals/equals2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.equals/vb/equals2.vb" id="Snippet2"::: ]]> @@ -886,6 +897,7 @@ The following example creates an array of objects that contain career statistics for running backs in American professional football. The five components consist of the player's name, the number of games in which he played, the number of carries or attempts, the total number of yards gained, and the number of touchdowns scored. The example displays the components of each tuple in the array in unsorted order, sorts the array, and then calls to display each tuple in sorted order. The output shows that the array has been sorted by name, which is the first component. Note that the example does not directly call the method. This method is called implicitly by the method for each element in the array. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/System.Collections.IStructuralComparable.CompareTo/compareto1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.compareto/vb/compareto1.vb" id="Snippet1"::: ]]> @@ -1040,6 +1052,7 @@ The following example illustrates the method. It displays an array of 5-tuple objects that contain the name of a state in the United States, its population in 1990 and 2000, its population change in this 10-year period, and the annual rate of population change. :::code language="csharp" source="~/snippets/csharp/System/TupleT1,T2,T3,T4,T5/ToString/tostring1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/TupleT1,T2,T3,T4,T5/ToString/tostring1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`5.tostring/vb/tostring1.vb" id="Snippet1"::: ]]>