Show / Hide Table of Contents

TryEncode Method

TryEncode(Span<byte>, out int)

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
Span<byte> destination

The Span into which the encoding will be placed.

int bytesWritten

On success, receives the number of bytes written into the destination.

Returns

bool

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.

In this article
Back to top Generated by DocFX