Encoding.TryGetBytes 方法

定義

如果目的地夠大,則從指定的唯讀範圍編碼為一組字元的位元組範圍。

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

參數

chars
ReadOnlySpan<Char>

範圍,其包含一組要編碼的字元。

bytes
Span<Byte>

保存已編碼位元組的位元組範圍。

bytesWritten
Int32

成功完成作業時,編碼為 bytes 的位元組數目。

傳回

true 如果所有字元都編碼為目的地,則為 ; false 如果目的地太小而無法包含所有編碼位元組,則為 。

適用於