CastArrayTFrom, TToSlice(Int32) Method

Gets a new CastArrayTFrom, TTo instance, which represents a subsection of the current instance with the specified startIndex. Please note that the size of TTo multiplied by startIndex must be divisible by the size of TFrom.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public CastArray<TFrom, TTo> Slice(
	int startIndex
)

Parameters

startIndex  Int32
The offset that points to the first item of the returned section.

Return Value

CastArrayTFrom, TTo
The subsection of the current CastArrayTFrom, TTo instance with the specified startIndex.

Remarks

  Note

If the size of TTo multiplied by startIndex is not divisible by the size of TFrom, then this method throws an ArgumentException. If the targeted platform supports the SpanT type and misaligned memory access, then you can try to use the AsSpan property and the MemoryMarshal.Cast method.

Exceptions

ArgumentOutOfRangeExceptionstartIndex is out of range.
ArgumentExceptionThe size of TTo multiplied by startIndex is not divisible by the size of TFrom.

See Also