ArrayExtensionsCast3DTFrom, TTo(ArraySegmentTFrom, Int32, Int32, Int32) Method

Reinterprets the specified arraySegment as a three-dimensional CastArray3DTFrom, TTo struct, while its element type is cast from TFrom to TTo. No heap allocation occurs when using this method.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public static CastArray3D<TFrom, TTo> Cast3D<TFrom, TTo>(
	this ArraySegment<TFrom> arraySegment,
	int depth,
	int height,
	int width
)
where TFrom : struct, new()
where TTo : struct, new()

Parameters

arraySegment  ArraySegmentTFrom
The desired underlying buffer for the CastArray3DTFrom, TTo instance to be created. It must have sufficient capacity for the specified dimensions.
depth  Int32
The depth of the array to be returned.
height  Int32
The height of the array to be returned.
width  Int32
The width of the array to be returned.

Type Parameters

TFrom
The actual element type of the specified arraySegment.
TTo
The reinterpreted element type after casting.

Return Value

CastArray3DTFrom, TTo
A CastArray3DTFrom, TTo instance using the specified arraySegment as its underlying buffer that has the specified dimensions.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ArraySegmentTFrom. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also