Table of Contents

Struct SpanByte

Namespace
System
Assembly
mscorlib.dll

Provides a type- and memory-safe representation of a contiguous region of arbitrary byte array

[CLSCompliant(false)]
public readonly ref struct SpanByte
Inherited Members

Constructors

SpanByte(byte[])

Creates a new System.SpanByte object over the entirety of a specified array.

public SpanByte(byte[] array)

Parameters

array byte[]

The array from which to create the System.Span object.

SpanByte(byte[], int, int)

Creates a new System.SpanByte object that includes a specified number of elements of an array starting at a specified index.

public SpanByte(byte[] array, int start, int length)

Parameters

array byte[]

The source array.

start int

The index of the first element to include in the new System.Span

length int

The number of elements to include in the new System.Span

Exceptions

ArgumentOutOfRangeException

array is null, but start or length is non-zero

-or-

start is outside the bounds of the array.

-or-

start + length exceed the number of elements in the array.

Properties

Empty

Returns an empty System.Span object.

public static SpanByte Empty { get; }

Property Value

SpanByte

IsEmpty

Returns a value that indicates whether the current System.Span is empty. true if the current span is empty; otherwise, false.

public bool IsEmpty { get; }

Property Value

bool

this[int]

Gets the element at the specified zero-based index.

public byte this[int index] { get; set; }

Parameters

index int

The zero-based index of the element.

Property Value

byte

The element at the specified index.

Exceptions

ArgumentOutOfRangeException

index is out of range.

Length

Returns the length of the current span.

public int Length { get; }

Property Value

int

Methods

CopyTo(SpanByte)

Copies the contents of this System.Span into a destination System.Span.

public void CopyTo(SpanByte destination)

Parameters

destination SpanByte

The destination System.Span object.

Exceptions

ArgumentException

destination is shorter than the source SpanByte.

Slice(int)

Forms a slice out of the current SpanByte that begins at a specified index.

public SpanByte Slice(int start)

Parameters

start int

The index at which to begin the slice.

Returns

SpanByte

A span that consists of all elements of the current span from start to the end of the span.

Exceptions

ArgumentOutOfRangeException

start is < zero or > Length.

Slice(int, int)

Forms a slice out of the current SpanByte starting at a specified index for a specified length.

public SpanByte Slice(int start, int length)

Parameters

start int

The index at which to begin this slice.

length int

The desired length for the slice.

Returns

SpanByte

A SpanByte that consists of length number of elements from the current SpanByte starting at start.

Exceptions

ArgumentOutOfRangeException

start or start + length is < zero or > Length.

ToArray()

Copies the contents of this SpanByte into a new array.

public byte[] ToArray()

Returns

byte[]

An array containing the data in the current span.

Operators

implicit operator SpanByte(byte[])

Implicit conversion of an array to a SpanByte.

public static implicit operator SpanByte(byte[] array)

Parameters

array byte[]

Returns

SpanByte