XmlSerializerSerialize(TextWriter, Object, XmlSerializationOptions) Method

Serializes the object passed in obj by the provided TextWriter object.

Definition

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

Parameters

writer  TextWriter
A TextWriter implementation (for example, a StringWriter) that will be used for serialization. The writer 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

ArgumentNullExceptionwriter must not be null.
InvalidOperationExceptionThe writer is closed.
NotSupportedExceptionSerialization is not supported with provided options
ReflectionExceptionThe object hierarchy to serialize contains circular reference.

See Also