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 是协变,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.

注解

当 @no__t null 时,返回 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 是协变的,数组的类型不完全是 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.

注解

当 @no__t null 时,返回 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 是协变的,数组的类型不完全是 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.

注解

当 @no__t null 时,返回 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 是协变的,数组的类型不完全是 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.

注解

当 @no__t null 时,返回 defaultReturns default when array is null.

适用于