Show / Hide Table of Contents

PeekTag Method

PeekTag(int)

Read the tag at the current data position, without advancing the reader.

C#
public int PeekTag(int tagLength = 1)

Parameters

Type Name Description
int tagLength

The length of the tag to read. If this argument is not given the default length of 1 will be used.

Returns

int

The tag as an int.

Exceptions

Type Condition
TlvException

The tagLength is unsupported, or there was not enough data to read.

Remarks

The caller passes in either no argument, or 1 or 2 as the tag length. No argument passed in means the default tag length of 1 will be used. If 1, the method returns the next byte as an int. If 2, the method returns the next two bytes as an int (e.g. 71 01 is returned as 0x00007101). If you pass in any other length other than 1 or 2, this method will throw an exception.

If there is no data at the current position (the entire encoding has been read), this method will throw an exception (check the HasData property to verify there is a tag available). If the tagLength is 2 and there is only one byte left in the encoding, this method throws an exception.

In this article
Back to top Generated by DocFX