Edit

Share via


AsnReader.TryReadPrimitiveBitString Method

Definition

Reads the next value as a BIT STRING with a specified tag, returning the contents as a ReadOnlyMemory<T> over the original data.

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

Parameters

unusedBitCount
Int32

On success, receives the number of bits in the last byte which were reported as "unused" by the writer.

value
ReadOnlyMemory<Byte>

On success, receives a ReadOnlyMemory<T> over the original data corresponding to the value of the BIT STRING.

expectedTag
Nullable<Asn1Tag>

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

Returns

true and advances the reader if the BIT STRING value had a primitive encoding, false and does not advance the reader if it had a constructed encoding.

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