UTF8Encoding.TryGetBytes 方法

定義

如果目的地夠大,則會將指定唯讀區段中的一組字元編碼成位元組區間。

public:
 override bool TryGetBytes(ReadOnlySpan<char> chars, Span<System::Byte> bytes, [Runtime::InteropServices::Out] int % bytesWritten);
public override bool TryGetBytes(ReadOnlySpan<char> chars, Span<byte> bytes, out int bytesWritten);
override this.TryGetBytes : ReadOnlySpan<char> * Span<byte> * int -> bool
Public Overrides 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 如果目的地太小,無法包含所有編碼的位元組。

適用於