TryEncode Method
TryEncode(Span<Byte>, out Int32)
Write out the encoding of the structure defined, placing the result into the destination.
C#
public bool TryEncode(Span<byte> destination, out int bytesWritten)
Parameters
Type | Name | Description |
---|---|---|
System.Span<System.Byte> | destination | The Span into which the encoding will be placed. |
System.Int32 | bytesWritten | On success, receives the number of bytes written into the destination. |
Returns
System.Boolean
A bool, true if the method successfully encoded, false otherwise.
Exceptions
Type | Condition |
---|---|
TlvException | The method is called before a schema has been completely entered. |
Remarks
This will try to write out the encoding. If the destination buffer is not big enough, the method will return false (no data was written).
Call this only after the schema has been completely entered (the outermost Nested TLV has been closed). If you call this before the schema has been completely entered, it can throw an exception.