XmlSerializerSerialize(Stream, Object, XmlSerializationOptions) Method

Serializes the object passed in obj into the provided Stream.

Definition

Namespace: KGySoft.Serialization.Xml
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
C#
public static void Serialize(
	Stream stream,
	Object? obj,
	XmlSerializationOptions options = XmlSerializationOptions.CompactSerializationOfPrimitiveArrays|XmlSerializationOptions.EscapeNewlineCharacters
)

Parameters

stream  Stream
A Stream used to write the XML document. The stream will not be closed after serialization.
obj  Object
The Object to serialize.
options  XmlSerializationOptions  (Optional)
Options for serialization. This parameter is optional.
Default value: CompactSerializationOfPrimitiveArrays, EscapeNewlineCharacters

Exceptions

ArgumentNullExceptionstream must not be null.
NotSupportedException

Serialization is not supported with provided options

- or -

The stream does not support writing.

ReflectionExceptionThe object hierarchy to serialize contains circular reference.
IOExceptionAn I/O error occurred.
ObjectDisposedExceptionThe stream is already closed.

See Also