Show / Hide Table of Contents

TryReadEncoded Method

TryReadEncoded(out ReadOnlyMemory<byte>, int)

Try to read the TLV at the current position. If this succeeds, return true and set the encoded argument to a new ReadOnlyMemory object containing the full TLV, and move the position to the byte beyond the current TLV.

C#
public bool TryReadEncoded(out ReadOnlyMemory<byte> encoded, int expectedTag)

Parameters

Type Name Description
ReadOnlyMemory<byte> encoded

The output parameter where the encoded TLV will be deposited.

int expectedTag

The tag that should be at the current position.

Returns

bool

A boolean, true if the read succeeds, false otherwise.

Remarks

This is the same as ReadEncoded, except this method will not throw an exception if there is an error in reading, only return false. That is, if the expected tag is not found at the current position, or the length octets are not a valid encoding, or there is not enough data in the buffer for the length given, this method will return false.

See the documentation for ReadEncoded for more information on what this method does.

In this article
Back to top Generated by DocFX