ArraySectionTCastTFrom, TTo Method

Reinterprets this ArraySectionT by returning a CastArrayTFrom, TTo struct, so its element type is cast from TFrom to TTo. This method can be used only when T in this ArraySectionT is a value type that contains no references.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public CastArray<TFrom, TTo> Cast<TFrom, TTo>()
where TFrom : struct, new(), T
where TTo : struct, new()

Type Parameters

TFrom
The actual element type of this ArraySectionT. Must be the same as T.
TTo
The reinterpreted element type after casting.

Return Value

CastArrayTFrom, TTo
A CastArrayTFrom, TTo instance for this ArraySectionT.

Remarks

If the size of TTo cannot be divided by the size of TFrom, then the cast result may not cover the whole original ArraySectionT to prevent exceeding beyond the available buffer.

See Also