Redigeeri

Jagamisviis:


MemoryExtensions.AsSpan Method

Definition

Overloads

AsSpan(String, Int32, Int32)

Creates a new read-only span over a portion of the target string from a specified position for a specified number of characters.

AsSpan(String, Range)

Creates a new ReadOnlySpan<T> over a portion of a target string using the range start and end indexes.

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, Index)

Creates a new ReadOnlySpan<T> 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 string.

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)

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)

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)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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, int start, int length);
public static ReadOnlySpan<char> AsSpan (this 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)

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

The read-only span representation of the string.

Exceptions

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

Remarks

Returns default when text is null.

Applies to

AsSpan(String, Range)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Creates a new ReadOnlySpan<T> over a portion of a target string using the range start and end indexes.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<char> AsSpan(System::String ^ text, Range range);
public static ReadOnlySpan<char> AsSpan (this string? text, Range range);
static member AsSpan : string * Range -> ReadOnlySpan<char>
<Extension()>
Public Function AsSpan (text As String, range As Range) As ReadOnlySpan(Of Char)

Parameters

text
String

The target string.

range
Range

The range that has start and end indexes to use for slicing the string.

Returns

Exceptions

text is null.

range's start or end index is not within the bounds of the string.

range's start index is greater than its end index.

Applies to

AsSpan(String, Int32)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

Parameters

text
String

The target string.

start
Int32

The index at which to begin this slice.

Returns

The read-only span representation of the string.

Exceptions

start is less than 0 or greater than text.Length.

Thrown when text is null.

Applies to

AsSpan(String, Index)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Creates a new ReadOnlySpan<T> 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, Index startIndex);
public static ReadOnlySpan<char> AsSpan (this string? text, Index startIndex);
static member AsSpan : string * Index -> ReadOnlySpan<char>
<Extension()>
Public Function AsSpan (text As String, startIndex As Index) As ReadOnlySpan(Of Char)

Parameters

text
String

The target string.

startIndex
Index

The index at which to begin this slice.

Returns

Exceptions

startIndex is less than 0 or greater than text.Length.

Applies to

AsSpan(String)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Creates a new read-only span over a string.

public:
[System::Runtime::CompilerServices::Extension]
 static ReadOnlySpan<char> AsSpan(System::String ^ text);
public static ReadOnlySpan<char> AsSpan (this 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)

Parameters

text
String

The target string.

Returns

The read-only span representation of the string.

Remarks

Returns default when text is null.

Applies to

AsSpan<T>(ArraySegment<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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)

Type Parameters

T

The type of the array segment.

Parameters

segment
ArraySegment<T>

The array segment to convert.

Returns

The span representation of the array segment.

Applies to

AsSpan<T>(T[])

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

Type Parameters

T

The type of the array.

Parameters

array
T[]

The array to convert.

Returns

The span representation of the array.

Applies to

AsSpan<T>(ArraySegment<T>, Index)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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)

Type Parameters

T

The type of the array segment.

Parameters

segment
ArraySegment<T>

The target array segment.

startIndex
Index

The index at which to begin the Span.

Returns

The span representation of the array segment.

Applies to

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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)

Type Parameters

T

The type of the array segment.

Parameters

segment
ArraySegment<T>

The target array segment.

start
Int32

The index at which to begin the san.

Returns

The span representation of the array segment.

Exceptions

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

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

Remarks

Returns default when segment is null.

Applies to

AsSpan<T>(ArraySegment<T>, Range)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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>
<Extension()>
Public Function AsSpan(Of T) (segment As ArraySegment(Of T), range As Range) As Span(Of T)

Type Parameters

T

The type of the array segment.

Parameters

segment
ArraySegment<T>

The target array segment.

range
Range

The range which has start and end indexes to use for slicing the array.

Returns

The span representation of the array segment.

Applies to

AsSpan<T>(T[], Index)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

Type Parameters

T

The array type.

Parameters

array
T[]

The array to convert.

startIndex
Index

The starting index.

Returns

The span representation of the array.

Applies to

AsSpan<T>(T[], Int32)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

Type Parameters

T

The type of the array.

Parameters

array
T[]

The array to convert.

start
Int32

The initial index from which the array will be converted.

Returns

The span representation of the array.

Applies to

AsSpan<T>(T[], Range)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

Type Parameters

T

The type of the array.

Parameters

array
T[]

The array to convert.

range
Range

The range of the array to convert.

Returns

The span representation of the array.

Applies to

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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)

Type Parameters

T

The type of the array segment.

Parameters

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.

Returns

The span representation 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

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

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

Type Parameters

T

The type of the array.

Parameters

array
T[]

The target array.

start
Int32

The index at which to begin the span.

length
Int32

The number of items in the span.

Returns

The span representation 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