NIndex.GetOffset(IntPtr) Method

Definition

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

C#
public IntPtr GetOffset(IntPtr length);

Parameters

length
IntPtr

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

Returns

IntPtr

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

Produkt Verzie
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)