Index.GetOffset(Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Calculate the offset from the start using the giving collection length.
public:
int GetOffset(int length);
public int GetOffset(int length);
member this.GetOffset : int -> int
Public Function GetOffset (length As Integer) As Integer
Parameters
- length
- Int32
The length of the collection that the Index will be used with. length has to be a positive value.
Returns
The offset.
Remarks
For performance reason, we don't validate the input length parameter and the returned offset value against negative values. we don't validate either the returned offset is greater than the input length. It is expected Index will be used with collections which always have non negative length/count. If the returned offset is negative and then used to index a collection will get out of range exception which will be same affect as the validation.