संपादित करें

इसके माध्यम से साझा किया गया


MemoryMarshal.CreateReadOnlySpanFromNullTerminated Method

Definition

Overloads

CreateReadOnlySpanFromNullTerminated(Byte*)

Creates a new read-only span for a null-terminated sequence of bytes.

CreateReadOnlySpanFromNullTerminated(Char*)

Creates a new read-only span for a null-terminated string.

CreateReadOnlySpanFromNullTerminated(Byte*)

Source:
MemoryMarshal.cs
Source:
MemoryMarshal.cs
Source:
MemoryMarshal.cs

Important

This API is not CLS-compliant.

Creates a new read-only span for a null-terminated sequence of bytes.

public:
 static ReadOnlySpan<System::Byte> CreateReadOnlySpanFromNullTerminated(System::Byte* value);
[System.CLSCompliant(false)]
public static ReadOnlySpan<byte> CreateReadOnlySpanFromNullTerminated (byte* value);
[<System.CLSCompliant(false)>]
static member CreateReadOnlySpanFromNullTerminated : nativeptr<byte> -> ReadOnlySpan<byte>

Parameters

value
Byte*

The pointer to the null-terminated sequence of bytes.

Returns

A read-only span representing the specified sequence of bytes, or an empty span if the pointer is null.

Attributes

Exceptions

The Length property of the new ReadOnlySpan<T> would exceed Int32.MaxValue.

Remarks

This method is typically used with byte sequences representing narrow character strings, such as ANSI or UTF-8 strings. The returned span does not include the null terminator, nor does this API attempt to intepret the contents of the byte sequence in any form.

Applies to

CreateReadOnlySpanFromNullTerminated(Char*)

Source:
MemoryMarshal.cs
Source:
MemoryMarshal.cs
Source:
MemoryMarshal.cs

Important

This API is not CLS-compliant.

Creates a new read-only span for a null-terminated string.

public:
 static ReadOnlySpan<char> CreateReadOnlySpanFromNullTerminated(char* value);
[System.CLSCompliant(false)]
public static ReadOnlySpan<char> CreateReadOnlySpanFromNullTerminated (char* value);
[<System.CLSCompliant(false)>]
static member CreateReadOnlySpanFromNullTerminated : nativeptr<char> -> ReadOnlySpan<char>

Parameters

value
Char*

The pointer to the null-terminated string of characters.

Returns

A read-only span representing the specified null-terminated string, or an empty span if the pointer is null.

Attributes

Exceptions

The Length property of the new ReadOnlySpan<T> would exceed Int32.MaxValue.

Remarks

The returned span does not include the null terminator.

Applies to