Skip to content
CShift0.32

Slice<T>

Struct · built-in type

struct Slice<T>

A view of a part of an array: a[i..j], a[..j], a[i..]. Nothing is copied, and writing slice[k] writes the array.

A slice has Length, s[i] (also s[^i]), foreach and slicing again; Slice<T>.ToArray copies. Functions that only read take a ReadOnlySlice, to which a Slice<T> and a T[] convert.

Name Description
Length The number of elements.
int Length

The number of elements.

Name Description
ToArray A new array with the elements of the slice.
Ptr A pointer to the first element (unsafe).
T[] ToArray()

A new array with the elements of the slice.

T* Ptr()

A pointer to the first element (unsafe).