CastArrayTFrom, TToGetElementUnaligned Method

Gets the element at the specified index with assuming misalignment for primitive TTo types.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
public TTo GetElementUnaligned(
	int index
)

Parameters

index  Int32
The index of the element to get.

Return Value

TTo
The element at the specified index.

Remarks

This method assumes misaligned address for primitive TTo items, and also validates index against Length. To omit range validation and still reading the elements assuming misalignment, use the GetElementReferenceUnsafe method with a compiler that supports members that return values by reference, and make sure you cast the type of the reference properly before dereferencing it.

Exceptions

IndexOutOfRangeExceptionindex is less than zero or greater or equal to Length.
NotSupportedException.NET Framework only: you access this member in a partially trusted AppDomain that does not allow executing unverifiable code.

See Also