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.
Calculates the offset from the start of the collection using the specified 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. Must be a positive value.
Returns
The offset.
Remarks
For performance reasons, this method does not validate if length
or the returned value are negative. It also doesn't validate if the returned value is greater than length
.
Collections are not expected to have a negative length/count. If this method's returned offset is negative and is then used to index a collection, the runtime will throw ArgumentOutOfRangeException, which will have the same effect as validation.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈