Del via


AsnReader.TryReadOctetString Method

Definition

Reads the next value as an OCTET STRING with a specified tag, copying the value into a provided destination buffer.

public bool TryReadOctetString (Span<byte> destination, out int bytesWritten, System.Formats.Asn1.Asn1Tag? expectedTag = default);
member this.TryReadOctetString : Span<byte> * int * Nullable<System.Formats.Asn1.Asn1Tag> -> bool
Public Function TryReadOctetString (destination As Span(Of Byte), ByRef bytesWritten As Integer, Optional expectedTag As Nullable(Of Asn1Tag) = Nothing) As Boolean

Parameters

destination
Span<Byte>

The buffer in which to write.

bytesWritten
Int32

On success, receives the number of bytes written to destination.

expectedTag
Nullable<Asn1Tag>

The tag to check for before reading, or null for the default tag (Universal 4).

Returns

true and advances the reader if destination had sufficient length to receive the value, otherwise false and the reader does not advance.

Exceptions

The next value does not have the correct tag.

-or-

The length encoding is not valid under the current encoding rules.

-or-

The contents are not valid under the current encoding rules.

expectedTag.TagClass is Universal, but expectedTag.TagValue is not correct for the method.

Applies to

See also