CastArrayTFrom, TToGetElementUnsafe Method

Gets 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 indexer instead.

Definition

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

Parameters

index  Int32
The index of the element to get.

Return Value

TTo
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.

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.
NullReferenceExceptionThe IsNull property returns .

See Also