MemoryExtensions.AsMemory 方法

定義

多載

AsMemory(String)

在目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over the portion of the target string.

AsMemory(String, Index)

在起始於指定索引的目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified index.

AsMemory(String, Int32)

在起始於指定字元位置的目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified character position.

AsMemory(String, Range)

在指定的目標字串範圍上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a specified range of the target string.

AsMemory(String, Int32, Int32)

在起始於指定位置且具有一個長度的目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a portion of the target string beginning at a specified position with a length.

AsMemory<T>(ArraySegment<T>)

在目標陣列區段部分上建立新記憶體區域。Creates a new memory region over the portion of the target array segment.

AsMemory<T>(T[])

在目標陣列上建立新記憶體區域。Creates a new memory region over the target array.

AsMemory<T>(ArraySegment<T>, Int32)

在起始於指定位置到區段結尾的目標陣列區段部分上建立新記憶體區域。Creates a new memory region over the portion of the target array segment starting at a specified position to the end of the segment.

AsMemory<T>(T[], Index)

在起始於指定索引到陣列結尾的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array starting at a specified index to the end of the array.

AsMemory<T>(T[], Int32)

在起始於指定位置到陣列結尾的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array starting at a specified position to the end of the array.

AsMemory<T>(T[], Range)

在起始於範圍開始索引 (含) 且結束於範圍結束索引 (不含) 的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array beginning at inclusive start index of the range and ending at the exclusive end index of the range.

AsMemory<T>(ArraySegment<T>, Int32, Int32)

在起始於指定位置且具有指定長度的目標陣列區段部分上建立新記憶體區域。Creates a new memory region over the portion of the target array segment beginning at a specified position with a specified length.

AsMemory<T>(T[], Int32, Int32)

在起始於指定位置且具有指定長度的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array beginning at a specified position with a specified length.

AsMemory(String)

在目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over the portion of the target string.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<char> AsMemory(System::String ^ text);
public static ReadOnlyMemory<char> AsMemory (this string text);
static member AsMemory : string -> ReadOnlyMemory<char>
<Extension()>
Public Function AsMemory (text As String) As ReadOnlyMemory(Of Char)

參數

text
String

目標字串。The target string.

傳回

字串的唯讀字元記憶體表示;如果 textnull,則為 defaultThe read-only character memory representation of the string, or default if text is null.

AsMemory(String, Index)

在起始於指定索引的目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified index.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<char> AsMemory(System::String ^ text, Index startIndex);
public static ReadOnlyMemory<char> AsMemory (this string text, Index startIndex);
static member AsMemory : string * Index -> ReadOnlyMemory<char>
<Extension()>
Public Function AsMemory (text As String, startIndex As Index) As ReadOnlyMemory(Of Char)

參數

text
String

目標字串。The target string.

startIndex
Index

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

傳回

字串的唯讀字元記憶體表示。The read-only character memory representation of the string.

AsMemory(String, Int32)

在起始於指定字元位置的目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified character position.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<char> AsMemory(System::String ^ text, int start);
public static ReadOnlyMemory<char> AsMemory (this string text, int start);
static member AsMemory : string * int -> ReadOnlyMemory<char>
<Extension()>
Public Function AsMemory (text As String, start As Integer) As ReadOnlyMemory(Of Char)

參數

text
String

目標字串。The target string.

start
Int32

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

傳回

字串的唯讀字元記憶體表示;如果 textnull,則為 defaultThe read-only character memory representation of the string, or default if text is null.

例外狀況

start 不在 text 的範圍內 (start 為 < 0 或 > text.Length)。start is not in the range of text (start is < 0 or > text.Length).

AsMemory(String, Range)

在指定的目標字串範圍上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a specified range of the target string.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<char> AsMemory(System::String ^ text, Range range);
public static ReadOnlyMemory<char> AsMemory (this string text, Range range);
static member AsMemory : string * Range -> ReadOnlyMemory<char>

參數

text
String

目標字串。The target string.

range
Range

表示已切割字串開頭和長度的範圍。The range that indicates the start and length of the sliced string.

傳回

字串的唯讀字元記憶體表示。The read-only character memory representation of the string.

AsMemory(String, Int32, Int32)

在起始於指定位置且具有一個長度的目標字串部分上建立新 ReadOnlyMemory<Char>Creates a new ReadOnlyMemory<Char> over a portion of the target string beginning at a specified position with a length.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlyMemory<char> AsMemory(System::String ^ text, int start, int length);
public static ReadOnlyMemory<char> AsMemory (this string text, int start, int length);
static member AsMemory : string * int * int -> ReadOnlyMemory<char>
<Extension()>
Public Function AsMemory (text As String, start As Integer, length As Integer) As ReadOnlyMemory(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.

傳回

字串的唯讀字元記憶體表示;如果 textnull,則為 defaultThe read-only character memory representation of the string, or default if text is null.

例外狀況

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

AsMemory<T>(ArraySegment<T>)

在目標陣列區段部分上建立新記憶體區域。Creates a new memory region over the portion of the target array segment.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(ArraySegment<T> segment);
public static Memory<T> AsMemory<T> (this ArraySegment<T> segment);
static member AsMemory : ArraySegment<'T> -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (segment As ArraySegment(Of T)) As Memory(Of T)

類型參數

T

區段的類型。The type of the segment.

參數

segment
ArraySegment<T>

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

傳回

區段的記憶體表示。The memory representation of the segment.

AsMemory<T>(T[])

在目標陣列上建立新記憶體區域。Creates a new memory region over the target array.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(cli::array <T> ^ array);
public static Memory<T> AsMemory<T> (this T[] array);
static member AsMemory : 'T[] -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (array As T()) As Memory(Of T)

類型參數

T

陣列的類型。The type of the array.

參數

array
T[]

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

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part of the array.

AsMemory<T>(ArraySegment<T>, Int32)

在起始於指定位置到區段結尾的目標陣列區段部分上建立新記憶體區域。Creates a new memory region over the portion of the target array segment starting at a specified position to the end of the segment.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(ArraySegment<T> segment, int start);
public static Memory<T> AsMemory<T> (this ArraySegment<T> segment, int start);
static member AsMemory : ArraySegment<'T> * int -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (segment As ArraySegment(Of T), start As Integer) As Memory(Of T)

類型參數

T

陣列的類型。The type of the array.

參數

segment
ArraySegment<T>

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

start
Int32

要開始記憶體的索引。The index at which to begin the memory.

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part of the array.

例外狀況

segment 是 Covariant,且 segment 的型別不完全是 T[]segment is covariant, and the type of segment is not exactly T[].

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

備註

segmentnull 時,傳回 defaultReturns default when segment is null.

AsMemory<T>(T[], Index)

在起始於指定索引到陣列結尾的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array starting at a specified index to the end of the array.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(cli::array <T> ^ array, Index startIndex);
public static Memory<T> AsMemory<T> (this T[] array, Index startIndex);
static member AsMemory : 'T[] * Index -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (array As T(), startIndex As Index) As Memory(Of T)

類型參數

T

陣列的類型。The type of the array.

參數

array
T[]

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

startIndex
Index

陣列的第一個位置。The first position of the array.

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part of the array.

AsMemory<T>(T[], Int32)

在起始於指定位置到陣列結尾的目標陣列部分上建立新記憶體區域。Creates a new memory region over the 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 Memory<T> AsMemory(cli::array <T> ^ array, int start);
public static Memory<T> AsMemory<T> (this T[] array, int start);
static member AsMemory : 'T[] * int -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (array As T(), start As Integer) As Memory(Of T)

類型參數

T

陣列的類型。The type of the array.

參數

array
T[]

目標陣列。The target array.

start
Int32

要開始記憶體的索引。The index at which to begin the memory.

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part of the array.

例外狀況

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

start 索引小於 0 或大於 array.Lengthstart index less than 0 or greater than array.Length.

備註

arraynull 時,傳回 defaultReturns default when array is null.

AsMemory<T>(T[], Range)

在起始於範圍開始索引 (含) 且結束於範圍結束索引 (不含) 的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array beginning at inclusive start index of the range and ending at the exclusive end index of the range.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(cli::array <T> ^ array, Range range);
public static Memory<T> AsMemory<T> (this T[] array, Range range);
static member AsMemory : 'T[] * Range -> Memory<'T>

類型參數

T

陣列的類型。The type of the array.

參數

array
T[]

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

range
Range

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

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part of the array.

AsMemory<T>(ArraySegment<T>, Int32, Int32)

在起始於指定位置且具有指定長度的目標陣列區段部分上建立新記憶體區域。Creates a new memory region over the portion of the target array segment beginning at a specified position with a specified length.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(ArraySegment<T> segment, int start, int length);
public static Memory<T> AsMemory<T> (this ArraySegment<T> segment, int start, int length);
static member AsMemory : ArraySegment<'T> * int * int -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (segment As ArraySegment(Of T), start As Integer, length As Integer) As Memory(Of T)

類型參數

T

陣列的類型。The type of the array.

參數

segment
ArraySegment<T>

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

start
Int32

要開始記憶體的索引。The index at which to begin the memory.

length
Int32

記憶體中的項目數。The number of items in the memory.

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part 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.

AsMemory<T>(T[], Int32, Int32)

在起始於指定位置且具有指定長度的目標陣列部分上建立新記憶體區域。Creates a new memory region over the portion of the target array beginning at a specified position with a specified length.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static Memory<T> AsMemory(cli::array <T> ^ array, int start, int length);
public static Memory<T> AsMemory<T> (this T[] array, int start, int length);
static member AsMemory : 'T[] * int * int -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (array As T(), start As Integer, length As Integer) As Memory(Of T)

類型參數

T

陣列的類型。The type of the array.

參數

array
T[]

目標陣列。The target array.

start
Int32

要開始記憶體區域的索引。The index at which to begin the memory region.

length
Int32

記憶體區域中的項目數。The number of items in the memory region.

傳回

完整或部分陣列的記憶體表示。The memory representation of the whole or part of the array.

例外狀況

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

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

備註

arraynull 時,傳回 defaultReturns default when array is null.

適用於