|
99 | 99 | - For task-based asynchronous operations, you can use an <xref:System.ArraySegment%601> object to ensure that each task operates on a distinct segment of the array. The following example divides an array into individual segments with up to ten elements. Each element in the segment is multiplied by its segment number. The result shows that using the <xref:System.ArraySegment%601> class to manipulate elements in this way changes the values of its underlying array.
|
100 | 100 |
|
101 | 101 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/segmentexample.cs" id="Snippet2":::
|
| 102 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/segmentexample.fs" id="Snippet2"::: |
102 | 103 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/segmentexample.vb" id="Snippet2":::
|
103 | 104 |
|
104 | 105 | Note, however, that although the <xref:System.ArraySegment%601> structure can be used to divide an array into distinct segments, the segments are not completely independent of one another. The <xref:System.ArraySegment%601.Array%2A> property returns the entire original array, not a copy of the array; therefore, changes made to the array returned by the <xref:System.ArraySegment%601.Array%2A> property are made to the original array. If this is undesirable, you should perform operations on a copy of the array, rather than an <xref:System.ArraySegment%601> object that represents a portion of the array.
|
|
111 | 112 |
|
112 | 113 | - Have the same number of elements.
|
113 | 114 |
|
114 |
| - If you want to retrieve an element by its index in the <xref:System.ArraySegment%601> object, you must cast it to an <xref:System.Collections.Generic.IList%601> object and retrieve it or modify it by using the <xref:System.Collections.Generic.IList%601.Item%2A?displayProperty=nameWithType> property. The following example retrieves the element in an <xref:System.ArraySegment%601> object that delimits a section of a string array. |
| 115 | + If you want to retrieve an element by its index in the <xref:System.ArraySegment%601> object, you must cast it to an <xref:System.Collections.Generic.IList%601> object and retrieve it or modify it by using the <xref:System.Collections.Generic.IList%601.Item%2A?displayProperty=nameWithType> property. Note that this is not necessary in F#. The following example retrieves the element in an <xref:System.ArraySegment%601> object that delimits a section of a string array. |
115 | 116 |
|
116 | 117 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.arraysegment.class/cs/example1.cs" interactive="try-dotnet" id="Snippet1":::
|
| 118 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.arraysegment.class/fs/example1.fs" id="Snippet1"::: |
117 | 119 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.arraysegment.class/vb/example1.vb" id="Snippet1":::
|
118 | 120 |
|
119 | 121 |
|
|
123 | 125 |
|
124 | 126 | :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1":::
|
125 | 127 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/arraysegment.cs" interactive="try-dotnet" id="Snippet1":::
|
| 128 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: |
126 | 129 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1":::
|
127 | 130 |
|
128 | 131 | ]]></format>
|
|
149 | 152 |
|
150 | 153 | :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1":::
|
151 | 154 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/arraysegment.cs" interactive="try-dotnet" id="Snippet1":::
|
| 155 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: |
152 | 156 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1":::
|
153 | 157 |
|
154 | 158 | ]]></format>
|
|
320 | 324 |
|
321 | 325 | :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1":::
|
322 | 326 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/arraysegment.cs" interactive="try-dotnet" id="Snippet1":::
|
| 327 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: |
323 | 328 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1":::
|
324 | 329 |
|
325 | 330 | ]]></format>
|
@@ -498,6 +503,7 @@ The underlying array of <paramref name="destination" /> is <paramref name="null"
|
498 | 503 |
|
499 | 504 | :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1":::
|
500 | 505 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/arraysegment.cs" id="Snippet1":::
|
| 506 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: |
501 | 507 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1":::
|
502 | 508 |
|
503 | 509 | ]]></format>
|
@@ -829,6 +835,7 @@ The underlying array of <paramref name="destination" /> is <paramref name="null"
|
829 | 835 |
|
830 | 836 | :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1":::
|
831 | 837 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.ArraySegment/CS/arraysegment.cs" id="Snippet1":::
|
| 838 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: |
832 | 839 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1":::
|
833 | 840 |
|
834 | 841 | ]]></format>
|
@@ -1585,6 +1592,7 @@ The underlying array of <paramref name="destination" /> is <paramref name="null"
|
1585 | 1592 | This member is an explicit interface member implementation. It can be used only when the <xref:System.ArraySegment%601> instance is cast to an <xref:System.Collections.Generic.IList%601> interface, as the following example shows.
|
1586 | 1593 |
|
1587 | 1594 | :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.arraysegment.class/cs/example1.cs" interactive="try-dotnet" id="Snippet1":::
|
| 1595 | + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.arraysegment.class/fs/example1.fs" id="Snippet1"::: |
1588 | 1596 | :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.arraysegment.class/vb/example1.vb" id="Snippet1":::
|
1589 | 1597 |
|
1590 | 1598 | ]]></format>
|
|
0 commit comments