MemoryExtensions.AsSpan MemoryExtensions.AsSpan MemoryExtensions.AsSpan MemoryExtensions.AsSpan Method

定義

多載

AsSpan(String, Int32, Int32) AsSpan(String, Int32, Int32) AsSpan(String, Int32, Int32) AsSpan(String, Int32, Int32)

在字串上建立新唯讀範圍。Creates a new read-only span over a string.

AsSpan(String, Int32) AsSpan(String, Int32) AsSpan(String, Int32) 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) AsSpan(String) AsSpan(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>) AsSpan<T>(ArraySegment<T>) AsSpan<T>(ArraySegment<T>) AsSpan<T>(ArraySegment<T>)

在目標陣列區段上建立新範圍。Creates a new span over a target array segment.

AsSpan<T>(T[]) AsSpan<T>(T[]) AsSpan<T>(T[]) AsSpan<T>(T[])

在目標陣列上建立新範圍。Creates a new span over a target array.

AsSpan<T>(ArraySegment<T>, Index) AsSpan<T>(ArraySegment<T>, Index) AsSpan<T>(ArraySegment<T>, Index) 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) AsSpan<T>(ArraySegment<T>, Int32) AsSpan<T>(ArraySegment<T>, Int32) 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) AsSpan<T>(ArraySegment<T>, Range) 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) AsSpan<T>(T[], Index) AsSpan<T>(T[], Index) 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) AsSpan<T>(T[], Int32) AsSpan<T>(T[], Int32) 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) AsSpan<T>(T[], Range) 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) AsSpan<T>(ArraySegment<T>, Int32, Int32) AsSpan<T>(ArraySegment<T>, Int32, Int32) 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) AsSpan<T>(T[], Int32, Int32) AsSpan<T>(T[], Int32, Int32) 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) AsSpan(String, Int32, Int32) AsSpan(String, Int32, Int32) 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 String String String

目標字串。The target string.

start
Int32 Int32 Int32 Int32

要開始此配量的索引。The index at which to begin this slice.

length
Int32 Int32 Int32 Int32

配量所需的長度。The desired length for the slice.

傳回

字串的唯讀範圍表示。The read-only span representation of the string.

例外狀況

startlengthstart + length 不在 text 的範圍內。start, length, or start + length is not in the range of text.

備註

當為textnull, 會傳回。 defaultReturns default when text is null.

AsSpan(String, Int32) AsSpan(String, Int32) AsSpan(String, Int32) 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 String String String

目標字串。The target string.

start
Int32 Int32 Int32 Int32

要開始此配量的索引。The index at which to begin this slice.

傳回

字串的唯讀範圍表示。The read-only span representation of the string.

例外狀況

start 小於 0 或大於 text.Lengthstart is less than 0 or greater than text.Length.

AsSpan(String) AsSpan(String) AsSpan(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.

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 String String String

目標字串。The target string.

傳回

字串的唯讀範圍表示。The read-only span representation of the string.

備註

當為textnull, 會傳回。 defaultReturns default when text is null.

AsSpan<T>(ArraySegment<T>) AsSpan<T>(ArraySegment<T>) AsSpan<T>(ArraySegment<T>) 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> ArraySegment<T> ArraySegment<T> ArraySegment<T>

要轉換的陣列區段。The array segment to convert.

傳回

陣列區段的範圍表示。The span representation of the array segment.

AsSpan<T>(T[]) AsSpan<T>(T[]) AsSpan<T>(T[]) 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) AsSpan<T>(ArraySegment<T>, Index) AsSpan<T>(ArraySegment<T>, Index) 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> ArraySegment<T> ArraySegment<T> ArraySegment<T>

目標陣列區段。The target array segment.

startIndex
Index Index Index Index

要開始範圍的索引。The index at which to begin the Span.

傳回

陣列區段的範圍表示。The span representation of the array segment.

AsSpan<T>(ArraySegment<T>, Int32) AsSpan<T>(ArraySegment<T>, Int32) AsSpan<T>(ArraySegment<T>, Int32) 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> ArraySegment<T> ArraySegment<T> ArraySegment<T>

目標陣列區段。The target array segment.

start
Int32 Int32 Int32 Int32

要開始範圍的索引。The index at which to begin the san.

傳回

陣列區段的範圍表示。The span representation of the array segment.

例外狀況

segment 是 Covariant,且陣列的類型不完全是 T[]segment is covariant, and the array's type is not exactly T[].

start 小於 0 或大於 segment.Countstart is less than 0 or greater than segment.Count.

備註

當為segmentnull, 會傳回。 defaultReturns default when segment is null.

AsSpan<T>(ArraySegment<T>, Range) AsSpan<T>(ArraySegment<T>, Range) 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> ArraySegment<T> ArraySegment<T> ArraySegment<T>

目標陣列區段。The target array segment.

range
Range Range 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) AsSpan<T>(T[], Index) AsSpan<T>(T[], Index) 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 Index Index Index

起始索引。The starting index.

傳回

陣列的範圍表示。The span representation of the array.

AsSpan<T>(T[], Int32) AsSpan<T>(T[], Int32) AsSpan<T>(T[], Int32) 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 Int32 Int32 Int32

要從中轉換陣列的初始索引。The initial index from which the array will be converted.

傳回

陣列的範圍表示。The span representation of the array.

AsSpan<T>(T[], Range) AsSpan<T>(T[], Range) 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 Range Range Range

要轉換的陣列範圍。The range of the array to convert.

傳回

陣列的範圍表示。The span representation of the array.

AsSpan<T>(ArraySegment<T>, Int32, Int32) AsSpan<T>(ArraySegment<T>, Int32, Int32) AsSpan<T>(ArraySegment<T>, Int32, Int32) 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> ArraySegment<T> ArraySegment<T> ArraySegment<T>

目標陣列區段。The target array segment.

start
Int32 Int32 Int32 Int32

要開始範圍的索引。The index at which to begin the span.

length
Int32 Int32 Int32 Int32

範圍中的項目數。The number of items in the span.

傳回

陣列的範圍表示。The span representation of the array.

例外狀況

segment 是 Covariant,且陣列的類型不完全是 T[]segment is covariant, and the array's type is not exactly T[].

startlengthstart + length 不在 segment 的範圍內。start, length, or start + length is not in the range of segment.

備註

當為segmentnull, 會傳回。 defaultReturns default when segment is null.

AsSpan<T>(T[], Int32, Int32) AsSpan<T>(T[], Int32, Int32) AsSpan<T>(T[], Int32, Int32) 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 Int32 Int32 Int32

要開始範圍的索引。The index at which to begin the span.

length
Int32 Int32 Int32 Int32

範圍中的項目數。The number of items in the span.

傳回

陣列的範圍表示。The span representation of the array.

例外狀況

array 是 Covariant,且陣列的類型不完全是 T[]"。array is covariant, and the array's type is not exactly T[]".

startlengthstart + length 不在 text 的範圍內。start, length, or start + length is not in the range of text.

備註

當為arraynull, 會傳回。 defaultReturns default when array is null.

適用於