Bewerken

Share via


Encoding.TryGetBytes Method

Definition

Encodes into a span of bytes a set of characters from the specified read-only span if the destination is large enough.

public:
 virtual bool TryGetBytes(ReadOnlySpan<char> chars, Span<System::Byte> bytes, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TryGetBytes (ReadOnlySpan<char> chars, Span<byte> bytes, out int bytesWritten);
abstract member TryGetBytes : ReadOnlySpan<char> * Span<byte> * int -> bool
override this.TryGetBytes : ReadOnlySpan<char> * Span<byte> * int -> bool
Public Overridable Function TryGetBytes (chars As ReadOnlySpan(Of Char), bytes As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean

Parameters

chars
ReadOnlySpan<Char>

The span containing the set of characters to encode.

bytes
Span<Byte>

The byte span to hold the encoded bytes.

bytesWritten
Int32

Upon successful completion of the operation, the number of bytes encoded into bytes.

Returns

true if all of the characters were encoded into the destination; false if the destination was too small to contain all the encoded bytes.

Applies to