|
46 | 46 | <remarks>
|
47 | 47 | <format type="text/markdown">< that is allocated on the stack rather than on the managed heap. Ref struct types have a number of restrictions to ensure that they cannot be promoted to the managed heap, including that they can't be boxed, they can't be assigned to variables of type <xref:System.Object>, `dynamic` or to any interface type, they can't be fields in a reference type, and they can't be used across `await` and `yield` boundaries. In addition, calls to two methods, <xref:System.Span%601.Equals(System.Object)> and <xref:System.Span%601.GetHashCode%2A>, throw a <xref:System.NotSupportedException>. |
| 49 | +`Span<T>` is a [ref struct](~/docs/csharp/language-reference/builtin-types/struct.md#ref-struct) that is allocated on the stack rather than on the managed heap. Ref struct types have a number of restrictions to ensure that they cannot be promoted to the managed heap, including that they can't be boxed, they can't be assigned to variables of type <xref:System.Object>, `dynamic` or to any interface type, they can't be fields in a reference type, and they can't be used across `await` and `yield` boundaries. In addition, calls to two methods, <xref:System.Span%601.Equals(System.Object)> and <xref:System.Span%601.GetHashCode%2A>, throw a <xref:System.NotSupportedException>. |
50 | 50 |
|
51 | 51 | > [!IMPORTANT]
|
52 | 52 | > Because it is a stack-only type, `Span<T>` is unsuitable for many scenarios that require storing references to buffers on the heap. This is true, for example, of routines that make asynchronous method calls. For such scenarios, you can use the complementary <xref:System.Memory%601?displayProperty=nameWithType> and <xref:System.ReadOnlyMemory%601?displayProperty=nameWithType> types.
|
@@ -394,7 +394,7 @@ This method copies all of `source` to `destination` even if `source` and `destin
|
394 | 394 | <format type="text/markdown">< that cannot be boxed and therefore cannot be converted to an <xref:System.Object>. |
| 397 | +- If `obj` is a <xref:System.Span%601>, the method call generates compiler error CS1503: "cannot convert from 'System.Span' to 'object'." This is because <xref:System.Span%601> is a [ref struct](~/docs/csharp/language-reference/builtin-types/struct.md#ref-struct) that cannot be boxed and therefore cannot be converted to an <xref:System.Object>. |
398 | 398 |
|
399 | 399 | - If the type of `obj` is not a <xref:System.Span%601>, the method call throws a <xref:System.NotSupportedException>.
|
400 | 400 |
|
@@ -543,7 +543,7 @@ Instead of calling the <xref:System.Span%601.GetEnumerator%2A> method directly,
|
543 | 543 | <remarks>
|
544 | 544 | <format type="text/markdown"><. It can be used for pinning a <xref:System.Span%601> in memory. It is required to support the use of a <xref:System.Span%601> within a [fixed](~/docs/csharp/language-reference/keywords/fixed-statement.md) statement. |
| 546 | +The `GetPinnableReference` method returns a [ref struct](~/docs/csharp/language-reference/builtin-types/struct.md#ref-struct). It can be used for pinning a <xref:System.Span%601> in memory. It is required to support the use of a <xref:System.Span%601> within a [fixed](~/docs/csharp/language-reference/keywords/fixed-statement.md) statement. |
547 | 547 |
|
548 | 548 | ]]></format>
|
549 | 549 | </remarks>
|
|
0 commit comments