TryReadEncoded Method
TryReadEncoded(out ReadOnlyMemory<Byte>, Int32)
Try to read the TLV at the current position. If this succeeds, return
true and set the encoded
argument to a new ReadOnlyMemory
object containing the full TLV, and move the position to the byte
beyond the current TLV.
public bool TryReadEncoded(out ReadOnlyMemory<byte> encoded, int expectedTag)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlyMemory<System.Byte> | encoded | The output parameter where the encoded TLV 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 ReadEncoded
, 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 ReadEncoded
for more information
on what this method does.