ASCIIEncoding.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 如果目的地太小而無法包含所有編碼位元組,則為 。

適用於