Generated C# Method Format and Calling Parameters

The signature for a C# BER stream-oriented encode method is as follows:

   public override void Encode (Asn1BerOutputStream outs, bool explicitTagging)

The outs argument is a reference of an Asn1BerOutputStream object that describes the output stream into which a message is being encoded. This must be created and initialized before calling any encode method. See the description of this class in the C# Run-Time Classes section for details on how this class is used.

The explicitTagging argument specifies whether or not an explicit tag should be applied to the encoded contents. The average user will almost always want to set this argument to true. The only time it would not be set to true is if a user wanted to just encode a contents field with no tag. This argument is used primarily by the compiler when generating internal calls to properly handle implicit and explicit tagging.

Unlike the C/C++ version, a negative value is never returned form encode methods to indicate an encoding failure. That is handled by the exception mechanism. All ASN1C C# exceptions are derived from the Asn1Exception base class. See the section on exceptions for a complete list and description of the various exceptions that can be thrown. If an I/O error occurs then the System.Exception is thrown.