diff --git a/snippets/fsharp/System/UIntPtr/Add/add1.fs b/snippets/fsharp/System/UIntPtr/Add/add1.fs new file mode 100644 index 00000000000..721aaaaaec7 --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/Add/add1.fs @@ -0,0 +1,11 @@ +// +open System + +let arr = [| 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 |] +let ptr = UIntPtr(uint arr[0]) +for i = 0 to arr.Length - 1 do + let newPtr = UIntPtr.Add(ptr, i) + printf $"{newPtr} " +// The example displays the following output: +// 1 2 3 4 5 6 7 8 9 10 +// \ No newline at end of file diff --git a/snippets/fsharp/System/UIntPtr/Add/fs.fsproj b/snippets/fsharp/System/UIntPtr/Add/fs.fsproj new file mode 100644 index 00000000000..95dfad9f45c --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/Add/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/UIntPtr/Subtract/fs.fsproj b/snippets/fsharp/System/UIntPtr/Subtract/fs.fsproj new file mode 100644 index 00000000000..d00db14a81b --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/Subtract/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/UIntPtr/Subtract/subtract1.fs b/snippets/fsharp/System/UIntPtr/Subtract/subtract1.fs new file mode 100644 index 00000000000..f84c2b3876b --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/Subtract/subtract1.fs @@ -0,0 +1,11 @@ +// +open System + +let arr = [| 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 |] +let ptr = UIntPtr(uint arr[arr.GetUpperBound 0]) +for i = 0 to arr.GetUpperBound 0 do + let newPtr = UIntPtr.Subtract(ptr, i) + printf $"{newPtr} " +// The example displays the following output: +// 10 9 8 7 6 5 4 3 2 1 +// \ No newline at end of file diff --git a/snippets/fsharp/System/UIntPtr/op_Addition/fs.fsproj b/snippets/fsharp/System/UIntPtr/op_Addition/fs.fsproj new file mode 100644 index 00000000000..d029d0369ed --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/op_Addition/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System/UIntPtr/op_Addition/op_addition1.fs b/snippets/fsharp/System/UIntPtr/op_Addition/op_addition1.fs new file mode 100644 index 00000000000..3b2a758c5d3 --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/op_Addition/op_addition1.fs @@ -0,0 +1,11 @@ +module op_addition1 + +open System + +// +let arr = [| 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 |] +let ptr = UIntPtr(uint arr[0]) +for i = 0 to arr.Length - 1 do + let newPtr = ptr + UIntPtr(uint i) + printfn $"{newPtr}" +// \ No newline at end of file diff --git a/snippets/fsharp/System/UIntPtr/op_Addition/op_subtraction1.fs b/snippets/fsharp/System/UIntPtr/op_Addition/op_subtraction1.fs new file mode 100644 index 00000000000..083fc99913c --- /dev/null +++ b/snippets/fsharp/System/UIntPtr/op_Addition/op_subtraction1.fs @@ -0,0 +1,11 @@ +module op_subtraction + +open System + +// +let arr = [| 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 |] +let ptr = UIntPtr(uint arr[arr.GetUpperBound 0]) +for i = 0 to arr.GetUpperBound 0 do + let newPtr = ptr - UIntPtr(uint i) + printf $"{newPtr} " +// \ No newline at end of file diff --git a/xml/System/UIntPtr.xml b/xml/System/UIntPtr.xml index 0a5dfbc754b..d88158af0b9 100644 --- a/xml/System/UIntPtr.xml +++ b/xml/System/UIntPtr.xml @@ -495,6 +495,7 @@ The following example instantiates a object that points to the beginning of a ten-element array, and then calls the method to iterate the elements in the array. :::code language="csharp" source="~/snippets/csharp/System/UIntPtr/Add/add1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/UIntPtr/Add/add1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.uintptr.add/vb/add1.vb" id="Snippet1"::: ]]> @@ -877,6 +878,7 @@ For this method matches the IEEE 754:2019 `minimu The method defines the addition operation for objects. It enables code such as the following. :::code language="csharp" source="~/snippets/csharp/System/UIntPtr/op_Addition/op_addition1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/UIntPtr/op_Addition/op_addition1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.uintptr.op_addition/vb/op_addition1.vb" id="Snippet1"::: Languages that do not support custom operators can call the method instead. @@ -1388,6 +1390,7 @@ For this method matches the IEEE 754:2019 `minimu The method defines the subtraction operation for objects. It enables code such as the following. :::code language="csharp" source="~/snippets/csharp/System/UIntPtr/op_Addition/op_subtraction1.cs" id="Snippet2"::: + :::code language="fsharp" source="~/snippets/fsharp/System/UIntPtr/op_Addition/op_subtraction1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.uintptr.op_addition/vb/op_subtraction1.vb" id="Snippet2"::: Languages that do not support custom operators can call the method instead. @@ -1720,6 +1723,7 @@ For this method matches the IEEE 754:2019 `minimu The following example instantiates an object that points to the end of a ten-element array, and then calls the method to iterate the elements in the array in reverse order. :::code language="csharp" source="~/snippets/csharp/System/UIntPtr/Subtract/subtract1.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System/UIntPtr/Subtract/subtract1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.uintptr.subtract/vb/subtract1.vb" id="Snippet1"::: ]]>