MemoryExtensions.AsMemory Method

Definition

Overloads

AsMemory(String)

Creates a new ReadOnlyMemory<Char> over the portion of the target string.

AsMemory(String, Index)

Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified index.

AsMemory(String, Int32)

Creates a new ReadOnlyMemory<Char> over a portion of the target string starting at a specified character position.

AsMemory(String, Range)

Creates a new ReadOnlyMemory<Char> over a specified range of the target string.

AsMemory(String, Int32, Int32)

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)

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);
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)

Parameters

text
String

The target string.

Returns

ReadOnlyMemory<Char>

The read-only character memory representation of the string, or default if text is null.

Applies to

Product Introduced

AsMemory(String, Index)

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);
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)

Parameters

text
String

The target string.

startIndex
Index

The index at which to begin this slice.

Returns

ReadOnlyMemory<Char>

The read-only character memory representation of the string.

Applies to

Product Introduced

AsMemory(String, Int32)

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);
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)

Parameters

text
String

The target string.

start
Int32

The index at which to begin this slice.

Returns

ReadOnlyMemory<Char>

The read-only character memory representation of the string, or default if text is null.

Exceptions

start is not in the range of text (start is < 0 or > text.Length).

Applies to

Product Introduced

AsMemory(String, Range)

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);
public static ReadOnlyMemory<char> AsMemory (this string text, Range range);
static member AsMemory : string * Range -> ReadOnlyMemory<char>
<Extension()>
Public Function AsMemory (text As String, range As Range) As ReadOnlyMemory(Of Char)

Parameters

text
String

The target string.

range
Range

The range that indicates the start and length of the sliced string.

Returns

ReadOnlyMemory<Char>

The read-only character memory representation of the string.

Applies to

Product Introduced

AsMemory(String, Int32, Int32)

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);
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)

Parameters

text
String

The target string.

start
Int32

The index at which to begin this slice.

length
Int32

The desired length for the slice.

Returns

ReadOnlyMemory<Char>

The read-only character memory representation of the string, or default if text is null.

Exceptions

start, length, or start + length is not in the range of text.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the segment.

Parameters

segment
ArraySegment<T>

The segment to convert.

Returns

Memory<T>

The memory representation of the segment.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the array.

Parameters

array
T[]

The array to convert.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the array.

Parameters

segment
ArraySegment<T>

The target array segment.

start
Int32

The index at which to begin the memory.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Exceptions

segment is covariant, and the type of segment is not exactly T[].

start is less than 0 or greater than segment.Count.

Remarks

Returns default when segment is null.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the array.

Parameters

array
T[]

The array to convert.

startIndex
Index

The first position of the array.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the array.

Parameters

array
T[]

The target array.

start
Int32

The index at which to begin the memory.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Exceptions

array is covariant, and the array's type is not exactly T[].

start index less than 0 or greater than array.Length.

Remarks

Returns default when array is null.

Applies to

Product Introduced

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);
public static Memory<T> AsMemory<T> (this T[] array, Range range);
static member AsMemory : 'T[] * Range -> Memory<'T>
<Extension()>
Public Function AsMemory(Of T) (array As T(), range As Range) As Memory(Of T)

Type Parameters

T

The type of the array.

Parameters

array
T[]

The array to convert.

range
Range

The range to convert from the array.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the array.

Parameters

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.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Exceptions

segment is covariant, and the array's type is not exactly T[].

start, length, or start + length is not in the range of segment.

Remarks

Returns default when segment is null.

Applies to

Product Introduced

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);
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)

Type Parameters

T

The type of the array.

Parameters

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.

Returns

Memory<T>

The memory representation of the whole or part of the array.

Exceptions

array is covariant, and the array's type is not exactly T[].

start, length, or start + length is not in the range of array.

Remarks

Returns default when array is null.

Applies to

Product Introduced