TryReadByte Method
TryReadByte(out Byte, Int32)
Try to read the TLV at the current position. If this succeeds, return
true and set the value
argument to the byte that is the V part
of the TLV, and move the position to the byte beyond the current TLV.
public bool TryReadByte(out byte value, int expectedTag)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The output parameter where the value will be deposited. |
System.Int32 | expectedTag | The tag that should be at the current position. |
Returns
A boolean, true
if the read succeeds, false
otherwise.
Remarks
This is the same as ReadByte
, 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
the value is not a single byte, or there is not enough data in the
buffer for the length given, this method will set value
to 0
and will return false
.
See the documentation for ReadByte
for more information
on what this method does.
Note that if there is a valid TLV with the expected tag, but the
length is not 1, this method will return false
.