Show / Hide Table of Contents

TryReadString Method

TryReadString(out string, int, Encoding)

Try to read the TLV at the current position. If this succeeds, return true and set the value argument to a string, and move the position to the byte beyond the current TLV.

C#
public bool TryReadString(out string value, int expectedTag, Encoding encoding)

Parameters

Type Name Description
string value

The output parameter where the value will be deposited.

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

bool

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

Remarks

This is the same as ReadString, 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 ReadString for more information on what this method does.

In this article
Back to top Generated by DocFX