Show / Hide Table of Contents

ReadString Method

ReadString(int, Encoding)

Read the TLV at the current position, return the value as a string, and move the position to the byte beyond the current TLV.

C#
public string ReadString(int expectedTag, Encoding encoding)

Parameters

Type Name Description
int expectedTag

The tag that should be at the current position.

Encoding encoding

The scheme the method will use to convert the byte array into a string, such as System.Text.Encoding.ASCII or UTF8.

Returns

string

A string, the value.

Exceptions

Type Condition
ArgumentNullException

The encoding argument is null.

TlvException

The tag was not the expected value, the tag or length is unsupported, or there was not enough data for the lengths given.

Remarks

See the documentation for the method TlvWriter.WriteString for a discussion of strings and encodings.

The method will verify that the tag is expected. If it is, it will read the length, verify that there are enough bytes in the buffer to read, then read the value (a byte array) and returning it as a string, converting the bytes array following the scheme specified by the encoding argument.

In this article
Back to top Generated by DocFX