Rediger

Del via


NIndex.GetOffset(IntPtr) Method

Definition

Calculates the offset from the start using the given collection length.

public:
 IntPtr GetOffset(IntPtr length);
public IntPtr GetOffset(IntPtr length);
member this.GetOffset : nativeint -> nativeint
Public Function GetOffset (length As IntPtr) As IntPtr

Parameters

length
IntPtr

nativeint

The length of the collection that the NIndex will be used with. Must be a positive value.

Returns

IntPtr

nativeint

Remarks

For performance reasons, the input length argument and the returned offset value aren't validated against negative values. Also, the returned offset might be greater than the input length. It is expected NIndex will be used with collections that always have a non-negative length/count. If the returned offset is negative and then used to NIndex a collection, an ArgumentOutOfRangeException is thrown, which has the same effect as the validation.

Applies to