Range Range Range Range Struct

定义

表示具有起始索引和结束索引的范围。Represents a range that has start and end indexes.

public value class Range : IEquatable<Range>
public struct Range : IEquatable<Range>
type Range = struct
Public Structure Range
Implements IEquatable(Of Range)
继承
实现

注解

#

RangeC#编译器使用来支持范围语法:Range is used by the C# compiler to support the range syntax:

    int[] someArray = new int[5] { 1, 2, 3, 4, 5 };
    int[] subArray1 = someArray[0..2];               // { 1, 2 }
    int[] subArray2 = someArray[1..^0];              // { 2, 3, 4, 5 }

构造函数

Range(Index, Index) Range(Index, Index) Range(Index, Index) Range(Index, Index)

使用指定的起始索引和结束索引初始化新的 Range 实例。Instantiates a new Range instance with the specified starting and ending indexes.

属性

All All All All

获取一个 Range 对象,该对象从第一个元素开始直至结束。Gets a Range object that starts from the first element to the end.

End End End End

获取一个表示范围的不包含结束索引的 IndexGets an Index that represents the exclusive end index of the range.

Start Start Start Start

获取 Range 的非包含起始索引。Gets the inclusive start index of the Range.

方法

EndAt(Index) EndAt(Index) EndAt(Index) EndAt(Index)

创建一个 Range 对象,该对象从集合中的第一个元素开始,直至指定的结束索引。Creates a Range object starting from the first element in the collection to a specified end index.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示当前实例是否与指定的对象相等。Returns a value that indicates whether the current instance is equal to a specified object.

Equals(Range) Equals(Range) Equals(Range) Equals(Range)

返回一个值,该值指示其他 Range 实例是否与指定的对象相等。Returns a value that indicates whether the current instance is equal to another Range object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

GetOffsetAndLength(Int32) GetOffsetAndLength(Int32) GetOffsetAndLength(Int32) GetOffsetAndLength(Int32)

返回一个包含范围的起始偏移量和长度的 Range.OffsetAndLength 实例。Returns a Range.OffsetAndLength instance with the starting offset and length of a range.

StartAt(Index) StartAt(Index) StartAt(Index) StartAt(Index)

返回一个新的 Range 实例,从指定的起始索引开始到集合末尾。Returns a new Range instance starting from a specified start index to the end of the collection.

ToString() ToString() ToString() ToString()

返回当前 Range 对象的字符串表示形式。Returns the string representation of the current Range object.

适用于