CastArrayTFrom, TToGetElementReferenceUnsafe Method

Gets the reference to the element at the specified index without any range check or validation. This method can even throw a NullReferenceException if the IsNull property returns . To validate index against Length use the GetElementReference method instead.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
[SecurityCriticalAttribute]
public ref TTo GetElementReferenceUnsafe(
	int index
)

Parameters

index  Int32
The index of the element to get the reference for.

Return Value

TTo
The reference to the element at the specified index.

Remarks

  Caution

You must ensure that index falls within Length, or at least in the bounds of the actual underlying array. Attempting to access protected memory may crash the runtime.

  Note

This method returns a value by reference. If this library is used by an older compiler that does not support such members, use the GetElementUnsafe/SetElementUnsafe methods instead.

Exceptions

VerificationException.NET Framework only: you execute this method in a partially trusted AppDomain that does not allow executing unverifiable code.
NullReferenceExceptionThe IsNull property returns .

See Also