TryReadString Method
TryReadString(out String, Int32, Encoding)
Try to read the TLV at the current position. If this succeeds, return
true and set the value
argument to a string
, and move
the position to the byte beyond the current TLV.
public bool TryReadString(out string value, int expectedTag, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The output parameter where the value will be deposited. |
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 boolean, true
if the read succeeds, false
otherwise.
Remarks
This is the same as ReadString
, 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 ReadString
for more information
on what this method does.