ReadByte Method
ReadByte(Int32)
Read the TLV at the current position, return the value as a byte, and move the position to the byte beyond the current TLV.
public byte ReadByte(int expectedTag)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | expectedTag | The tag that should be at the current position. |
Returns
A byte, the value.
Exceptions
Type | Condition |
---|---|
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
The method will verify that the tag is expected. If it is, it will read the length, verify that it is one, then read that one-byte value, and return it.
If the length of the value is not 1 (even if it is 0), this method will not advance the reader and throw an exception.
If the tag at the current position in the encoding is not what was given as the expectedTag, or if the tag and/or length make up an invalid encoding, or if there are not enough bytes left in the encoding to read the tag, length, and value, this method will not advance the reader and throw an exception.