MemoryExtensions.AsSpan 方法
定义
重载
AsSpan(String, Int32, Int32) |
在字符串上创建新的只读跨度。Creates a new read-only span over a string. |
AsSpan(String, Int32) |
从指定位置到字符串结尾,在目标字符串的一部分上创建新的只读跨度。Creates a new read-only span over a portion of the target string from a specified position to the end of the string. |
AsSpan(String) |
从指定字符数量的指定位置在目标字符串的一部分上创建新的只读跨度。Creates a new read-only span over a portion of the target string from a specified position for a specified number of characters. |
AsSpan<T>(ArraySegment<T>) |
在目标数组段上创建新的跨度。Creates a new span over a target array segment. |
AsSpan<T>(T[]) |
在目标数组上创建新的跨度。Creates a new span over a target array. |
AsSpan<T>(ArraySegment<T>, Index) |
在目标数组段的一部分上创建新的跨度,从指定的索引开始,以段的末尾结束。Creates a new span over a portion of the target array segment beginning at a specified index and ending at the end of the segment. |
AsSpan<T>(ArraySegment<T>, Int32) |
从指定位置到段的结尾,在目标数组段的一部分上创建新的跨度。Creates a new span over a portion of a target array segment from a specified position to the end of the segment. |
AsSpan<T>(ArraySegment<T>, Range) |
使用范围起始和结束索引在目标数组段的一部分上创建新的跨度。Creates a new span over a portion of a target array segment using the range start and end indexes. |
AsSpan<T>(T[], Index) |
在由 Index 值定义的目标数组部分上创建新的跨度。Creates a new span over the portion of the target array defined by an Index value. |
AsSpan<T>(T[], Int32) |
从指定位置开始到数组的结尾,在目标数组的一部分上创建一个新的跨度。Creates a new span over a portion of the target array starting at a specified position to the end of the array. |
AsSpan<T>(T[], Range) |
在由 Range 值定义的目标数组部分上创建新的跨度。Creates a new span over a portion of a target array defined by a Range value. |
AsSpan<T>(ArraySegment<T>, Int32, Int32) |
从指定长度的指定位置在目标数组段的一部分上创建新的跨度。Creates a new span over a portion of a target array segment from a specified position for a specified length. |
AsSpan<T>(T[], Int32, Int32) |
从指定长度的指定位置在目标数组的一部分上创建新的跨度。Creates a new span over the portion of the target array beginning at a specified position for a specified length. |
AsSpan(String, Int32, Int32)
在字符串上创建新的只读跨度。Creates a new read-only span over a string.
public:
[System::Runtime::CompilerServices::Extension]
static ReadOnlySpan<char> AsSpan(System::String ^ text, int start, int length);
public static ReadOnlySpan<char> AsSpan (this string text, int start, int length);
static member AsSpan : string * int * int -> ReadOnlySpan<char>
<Extension()>
Public Function AsSpan (text As String, start As Integer, length As Integer) As ReadOnlySpan(Of Char)
参数
- text
- String
目标字符串。The target string.
- start
- Int32
开始切片处的索引。The index at which to begin this slice.
- length
- Int32
切片所需的长度。The desired length for the slice.
返回
字符串的只读跨度表示形式。The read-only span representation of the string.
异常
start
、length
或 start
+ length
不在 text
的范围内。start
, length
, or start
+ length
is not in the range of text
.
注解
当 @no__t null
时,返回 default
。Returns default
when text
is null
.
AsSpan(String, Int32)
从指定位置到字符串结尾,在目标字符串的一部分上创建新的只读跨度。Creates a new read-only span over a portion of the target string from a specified position to the end of the string.
public:
[System::Runtime::CompilerServices::Extension]
static ReadOnlySpan<char> AsSpan(System::String ^ text, int start);
public static ReadOnlySpan<char> AsSpan (this string text, int start);
static member AsSpan : string * int -> ReadOnlySpan<char>
<Extension()>
Public Function AsSpan (text As String, start As Integer) As ReadOnlySpan(Of Char)
参数
- text
- String
目标字符串。The target string.
- start
- Int32
开始切片处的索引。The index at which to begin this slice.
返回
字符串的只读跨度表示形式。The read-only span representation of the string.
异常
text
为 null
。text
is null
.
start
小于 0 或大于 text.Length
。start
is less than 0 or greater than text.Length
.
AsSpan(String)
从指定字符数量的指定位置在目标字符串的一部分上创建新的只读跨度。Creates a new read-only span over a portion of the target string from a specified position for a specified number of characters.
public:
[System::Runtime::CompilerServices::Extension]
static ReadOnlySpan<char> AsSpan(System::String ^ text);
public static ReadOnlySpan<char> AsSpan (this string text);
static member AsSpan : string -> ReadOnlySpan<char>
<Extension()>
Public Function AsSpan (text As String) As ReadOnlySpan(Of Char)
参数
- text
- String
目标字符串。The target string.
返回
字符串的只读跨度表示形式。The read-only span representation of the string.
注解
当 @no__t null
时,返回 default
。Returns default
when text
is null
.
AsSpan<T>(ArraySegment<T>)
在目标数组段上创建新的跨度。Creates a new span over a target array segment.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(ArraySegment<T> segment);
public static Span<T> AsSpan<T> (this ArraySegment<T> segment);
static member AsSpan : ArraySegment<'T> -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (segment As ArraySegment(Of T)) As Span(Of T)
类型参数
- T
数组段的类型。The type of the array segment.
参数
- segment
- ArraySegment<T>
要写入的数组段。The array segment to convert.
返回
数组段的跨度表示形式。The span representation of the array segment.
AsSpan<T>(T[])
在目标数组上创建新的跨度。Creates a new span over a target array.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(cli::array <T> ^ array);
public static Span<T> AsSpan<T> (this T[] array);
static member AsSpan : 'T[] -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (array As T()) As Span(Of T)
类型参数
- T
数组的类型。The type of the array.
参数
- array
- T[]
要转换的数组。The array to convert.
返回
数组的跨度表示形式。The span representation of the array.
AsSpan<T>(ArraySegment<T>, Index)
在目标数组段的一部分上创建新的跨度,从指定的索引开始,以段的末尾结束。Creates a new span over a portion of the target array segment beginning at a specified index and ending at the end of the segment.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(ArraySegment<T> segment, Index startIndex);
public static Span<T> AsSpan<T> (this ArraySegment<T> segment, Index startIndex);
static member AsSpan : ArraySegment<'T> * Index -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (segment As ArraySegment(Of T), startIndex As Index) As Span(Of T)
类型参数
- T
数组段的类型。The type of the array segment.
参数
- segment
- ArraySegment<T>
目标数组段。The target array segment.
- startIndex
- Index
开始跨度处的索引。The index at which to begin the Span.
返回
数组段的跨度表示形式。The span representation of the array segment.
AsSpan<T>(ArraySegment<T>, Int32)
从指定位置到段的结尾,在目标数组段的一部分上创建新的跨度。Creates a new span over a portion of a target array segment from a specified position to the end of the segment.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(ArraySegment<T> segment, int start);
public static Span<T> AsSpan<T> (this ArraySegment<T> segment, int start);
static member AsSpan : ArraySegment<'T> * int -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (segment As ArraySegment(Of T), start As Integer) As Span(Of T)
类型参数
- T
数组段的类型。The type of the array segment.
参数
- segment
- ArraySegment<T>
目标数组段。The target array segment.
- start
- Int32
开始跨度处的索引。The index at which to begin the san.
返回
数组段的跨度表示形式。The span representation of the array segment.
异常
segment
是协变的,数组的类型不完全是 T[]
。segment
is covariant, and the array's type is not exactly T[]
.
start
小于 0 或大于 segment.Count
。start
is less than 0 or greater than segment.Count
.
注解
当 @no__t null
时,返回 default
。Returns default
when segment
is null
.
AsSpan<T>(ArraySegment<T>, Range)
使用范围起始和结束索引在目标数组段的一部分上创建新的跨度。Creates a new span over a portion of a target array segment using the range start and end indexes.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(ArraySegment<T> segment, Range range);
public static Span<T> AsSpan<T> (this ArraySegment<T> segment, Range range);
static member AsSpan : ArraySegment<'T> * Range -> Span<'T>
类型参数
- T
数组段的类型。The type of the array segment.
参数
- segment
- ArraySegment<T>
目标数组段。The target array segment.
- range
- Range
带有开始和结束索引的范围,用于对数组进行切片。The range which has start and end indexes to use for slicing the array.
返回
数组段的跨度表示形式。The span representation of the array segment.
AsSpan<T>(T[], Index)
在由 Index 值定义的目标数组部分上创建新的跨度。Creates a new span over the portion of the target array defined by an Index value.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(cli::array <T> ^ array, Index startIndex);
public static Span<T> AsSpan<T> (this T[] array, Index startIndex);
static member AsSpan : 'T[] * Index -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (array As T(), startIndex As Index) As Span(Of T)
类型参数
- T
数组类型。The array type.
参数
- array
- T[]
要转换的数组。The array to convert.
- startIndex
- Index
起始索引。The starting index.
返回
数组的跨度表示形式。The span representation of the array.
AsSpan<T>(T[], Int32)
从指定位置开始到数组的结尾,在目标数组的一部分上创建一个新的跨度。Creates a new span over a portion of the target array starting at a specified position to the end of the array.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(cli::array <T> ^ array, int start);
public static Span<T> AsSpan<T> (this T[] array, int start);
static member AsSpan : 'T[] * int -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (array As T(), start As Integer) As Span(Of T)
类型参数
- T
数组的类型。The type of the array.
参数
- array
- T[]
要转换的数组。The array to convert.
- start
- Int32
转换数组的初始索引。The initial index from which the array will be converted.
返回
数组的跨度表示形式。The span representation of the array.
AsSpan<T>(T[], Range)
在由 Range 值定义的目标数组部分上创建新的跨度。Creates a new span over a portion of a target array defined by a Range value.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(cli::array <T> ^ array, Range range);
public static Span<T> AsSpan<T> (this T[] array, Range range);
static member AsSpan : 'T[] * Range -> Span<'T>
类型参数
- T
数组的类型。The type of the array.
参数
- array
- T[]
要转换的数组。The array to convert.
- range
- Range
要转换的数组范围。The range of the array to convert.
返回
数组的跨度表示形式。The span representation of the array.
AsSpan<T>(ArraySegment<T>, Int32, Int32)
从指定长度的指定位置在目标数组段的一部分上创建新的跨度。Creates a new span over a portion of a target array segment from a specified position for a specified length.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(ArraySegment<T> segment, int start, int length);
public static Span<T> AsSpan<T> (this ArraySegment<T> segment, int start, int length);
static member AsSpan : ArraySegment<'T> * int * int -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (segment As ArraySegment(Of T), start As Integer, length As Integer) As Span(Of T)
类型参数
- T
数组段的类型。The type of the array segment.
参数
- segment
- ArraySegment<T>
目标数组段。The target array segment.
- start
- Int32
开始跨度处的索引。The index at which to begin the span.
- length
- Int32
跨度中的项数。The number of items in the span.
返回
数组的跨度表示形式。The span representation of the array.
异常
segment
是协变的,数组的类型不完全是 T[]
。segment
is covariant, and the array's type is not exactly T[]
.
start
、length
或 start
+ length
不在 segment
的范围内。start
, length
, or start
+ length
is not in the range of segment
.
注解
当 @no__t null
时,返回 default
。Returns default
when segment
is null
.
AsSpan<T>(T[], Int32, Int32)
从指定长度的指定位置在目标数组的一部分上创建新的跨度。Creates a new span over the portion of the target array beginning at a specified position for a specified length.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static Span<T> AsSpan(cli::array <T> ^ array, int start, int length);
public static Span<T> AsSpan<T> (this T[] array, int start, int length);
static member AsSpan : 'T[] * int * int -> Span<'T>
<Extension()>
Public Function AsSpan(Of T) (array As T(), start As Integer, length As Integer) As Span(Of T)
类型参数
- T
数组的类型。The type of the array.
参数
- array
- T[]
目标数组。The target array.
- start
- Int32
开始跨度处的索引。The index at which to begin the span.
- length
- Int32
跨度中的项数。The number of items in the span.
返回
数组的跨度表示形式。The span representation of the array.
异常
array
是协变的,数组的类型不完全是 T[]
"。array
is covariant, and the array's type is not exactly T[]
".
start
、length
或 start
+ length
不在 text
的范围内。start
, length
, or start
+ length
is not in the range of text
.
注解
当 @no__t null
时,返回 default
。Returns default
when array
is null
.