ReadString Method
ReadString(Int32, 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.
public string ReadString(int expectedTag, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | expectedTag | The tag that should be at the current position. |
System.Text.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
A string, the value.
Exceptions
Type | Condition |
---|---|
System.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.