CastArray3DTFrom, TToGetElementUnsafe Method

Gets the element at the specified indices without any range check or validation. This method can even throw a NullReferenceException if the IsNull property returns . To validate the coordinates against Length use the appropriate indexer instead. If TTo is a primitive type with misalignment, consider to use the GetElementUnaligned method instead. Parameter order is the same as in case of a regular three-dimensional array.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
[SecurityCriticalAttribute]
public TTo GetElementUnsafe(
	int z,
	int y,
	int x
)

Parameters

z  Int32
The Z-coordinate (depth index) of the item to get the reference for.
y  Int32
The Y-coordinate (row index) of the item to get.
x  Int32
The X-coordinate (column index) of the item to get.

Return Value

TTo
The element at the specified indices.

Remarks

  Caution

You must ensure that the specified indices designate an element in the bounds of the actual underlying array. Attempting to access protected memory may crash the runtime.

If the compiler you use supports members that return a value by reference, you can also use the GetElementReferenceUnsafe method.

  Note

If TTo is a primitive type of size larger than 1 byte, and unaligned memory access is not supported by the executing architecture (e.g. ARM), consider to call the GetElementUnaligned method instead to avoid a possible DataMisalignedException.

If the compiler you use supports members that return a value by reference, you can also use the GetElementReferenceUnsafe method.

Exceptions

NotSupportedException.NET Framework only: you execute this method in a partially trusted AppDomain that does not allow executing unverifiable code.
NullReferenceExceptionIsNull is .
DataMisalignedExceptionTTo is a primitive type of size larger than 1 byte, the address of the result is not properly aligned at the specified indices, and the executing architecture does not support misaligned memory access (e.g. ARM).

See Also