Table of Contents

Method AsBytes

Namespace
Zyl.ExSpans
Assembly
ExSpans.Core.dll

AsBytes<T>(ExSpan<T>)

Casts a ExSpan of one primitive type T to ExSpan of bytes. That type may not contain pointers or references. This is checked at runtime in order to preserve type safety (将一个基元类型T的ExSpan 转换为字节的ExSpan. 该类型不能包含指针或引用. 它会在运行时检查这一点, 以保护类型安全).

public static ExSpan<byte> AsBytes<T>(ExSpan<T> span) where T : struct

Parameters

span ExSpan<T>

The source slice, of type T (T 类型的源切片).

Returns

ExSpan<byte>

A ExSpan of type byte (byte 类型的 ExSpan).

Type Parameters

T

The element type (元素的类型).

Exceptions

ArgumentException

Thrown when T contains pointers.

OverflowException

Thrown if the Length property of the new ExSpan would exceed MaxValue.

AsBytes<T>(ReadOnlyExSpan<T>)

Casts a ReadOnlyExSpan of one primitive type T to ReadOnlyExSpan of bytes. That type may not contain pointers or references. This is checked at runtime in order to preserve type safety. (将一个基元类型T的ExSpan 转换为字节的ReadOnlyExSpan. 该类型不能包含指针或引用. 它会在运行时检查这一点, 以保护类型安全).

public static ReadOnlyExSpan<byte> AsBytes<T>(ReadOnlyExSpan<T> span) where T : struct

Parameters

span ReadOnlyExSpan<T>

The source slice, of type T (T 类型的源切片).

Returns

ReadOnlyExSpan<byte>

A ReadOnlyExSpan of type byte (byte 类型的 ReadOnlyExSpan).

Type Parameters

T

The element type (元素的类型).

Exceptions

ArgumentException

Thrown when T contains pointers.

OverflowException

Thrown if the Length property of the new ExSpan would exceed MaxValue.