TryReadInt32 Method
TryReadInt32(out Int32, Int32, Boolean)
Try to read the TLV at the current position. If this succeeds, return
true and set the value
argument to the int that is the V part
of the TLV, and move the position to the byte beyond the current TLV.
public bool TryReadInt32(out int value, int expectedTag, bool bigEndian = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The output parameter where the value will be deposited. |
System.Int32 | expectedTag | The tag that should be at the current position. |
System.Boolean | bigEndian | Specifies whether the result should be returned as big endian (true or no argument given) or little endian (false). |
Returns
A boolean, true
if the read succeeds, false
otherwise.
Remarks
This is the same as ReadInt32
, 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 exactly four bytes, 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 ReadInt32
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 4, this method will return false
.