|
32 | 32 |
|
33 | 33 | ## Remarks
|
34 | 34 |
|
35 |
| -Like <xref:System.Span%601>, `Memory<T>` represents a contiguous region of memory. Unlike <xref:System.Span%601>, however, `Memory<T>` is not a [ref struct](~/doocs/csharp/reference-semantics-with-value-types?view=netcore-2.1.md#ref-struct-type). This means that `Memory<T>` can be backed by: |
36 |
| -
|
37 |
| -- An array. |
38 |
| -- A string (a sequence of characters). |
39 |
| -- A <xref:System.Runtime.InteropServices.SafeHandle>. |
40 |
| -
|
41 |
| -`Memory<T>` cannot be backed by transient unmanaged memory, such as memory available by using [stackalloc](~/docs/csharp/language-reference/keywords/stackalloc.md). |
42 |
| -
|
43 |
| -Because the memory allocated to the `Memory<T>` structure is placed on the managed heap, it does not have the same restrictions as a <xref:System.Span%601> instance. In particular: |
| 35 | +Like <xref:System.Span%601>, `Memory<T>` represents a contiguous region of memory. Unlike <xref:System.Span%601>, however, `Memory<T>` is not a [ref struct](~/doocs/csharp/reference-semantics-with-value-types?view=netcore-2.1.md#ref-struct-type). This means that `Memory<T>` can be placed on the managed heap, whereas <xref:System.Span%601> cannot. As a result, the `Memory<T>` structure does not have the same restrictions as a <xref:System.Span%601> instance. In particular: |
44 | 36 |
|
45 | 37 | - It can be used as a field in a class.
|
46 | 38 |
|
47 | 39 | - It can be used across `await` and `yield` boundaries.
|
48 | 40 |
|
49 | 41 | In addition to `Memory<T>`, you can use <xref:System.ReadOnlyMemory%601?displayProperty=nameWithType> to represent immutable or read-only memory.
|
50 | 42 |
|
51 |
| -### Memory<T> basics |
52 |
| -
|
53 |
| -
|
54 | 43 | ]]></format>
|
55 | 44 | </remarks>
|
56 | 45 | </Docs>
|
@@ -79,12 +68,17 @@ In addition to `Memory<T>`, you can use <xref:System.ReadOnlyMemory%601?displayP
|
79 | 68 | <remarks>
|
80 | 69 | <format type="text/markdown"><![CDATA[
|
81 | 70 |
|
82 |
| -If `array` is `null`, this constructor returns a `null` <xref:System.Memory%601> object. |
| 71 | +If `array` is `null`, this constructor returns a <xref:System.Memory%601> object with a `default<T>` value. |
83 | 72 |
|
84 | 73 | ]]></format>
|
85 | 74 | </remarks>
|
86 | 75 | <exception cref="T:System.ArrayTypeMismatchException">
|
87 |
| - <paramref name="T" /> is a reference type, and <paramref name="array" /> is not an array of type <paramref name="T" />.</exception> |
| 76 | + <paramref name="T" /> is a reference type, and <paramref name="array" /> is not an array of type <paramref name="T" />. |
| 77 | + |
| 78 | +-or- |
| 79 | + |
| 80 | +The array is <see href="~/docs/csharp/programming-guide/concepts/covariance-contravariance/index.md" />covariant.</see> |
| 81 | + </exception> |
88 | 82 | </Docs>
|
89 | 83 | </Member>
|
90 | 84 | <Member MemberName=".ctor">
|
@@ -115,7 +109,7 @@ If `array` is `null`, this constructor returns a `null` <xref:System.Memory%601>
|
115 | 109 | <remarks>
|
116 | 110 | <format type="text/markdown"><![CDATA[
|
117 | 111 |
|
118 |
| -If `array` is `null`, this constructor returns a `null` <xref:System.Memory%601> object. |
| 112 | +If `array` is `null`, this constructor returns a <xref:System.Memory%601> object with a `default<T>` value. |
119 | 113 |
|
120 | 114 | ]]></format>
|
121 | 115 | </remarks>
|
@@ -219,7 +213,9 @@ The two objects are equal if:
|
219 | 213 | - `other` is a <xref:System.Memory%601> or <xref:System.ReadOnlyMemory%601> object.
|
220 | 214 |
|
221 | 215 | - Both objects point to the same array and have the same length.
|
222 |
| - |
| 216 | +
|
| 217 | +The `Equals(Memory<T>)` method performs a test for reference equality; it does not compare the elements of <xref:Memory%601> for equality. |
| 218 | +
|
223 | 219 | ]]></format>
|
224 | 220 | </remarks>
|
225 | 221 | </Docs>
|
@@ -518,7 +514,7 @@ The garbage collector will not move the memory until the returned <xref:T:System
|
518 | 514 | <param name="start">The index at which to begin the slice.</param>
|
519 | 515 | <param name="length">The number of elements to include in the slice.</param>
|
520 | 516 | <summary>Forms a slice out of the current memory starting at a specified index for a specified length.</summary>
|
521 |
| - <returns>An object that <paramref name="length" /> elements from the current instance starting at <paramref name="start" />. </returns> |
| 517 | + <returns>An object that contains <paramref name="length" /> elements from the current instance starting at <paramref name="start" />. </returns> |
522 | 518 | <remarks>To be added.</remarks>
|
523 | 519 | <exception cref="T:System.ArgumentOutOfRangeExceptionException"><paramref name="start" /> is less than zero or greater than or equal to <see cref="P:Memory`1.Length" />.
|
524 | 520 |
|
|
0 commit comments