XmlSerializerSerialize(String, Object, XmlSerializationOptions) Method

Serializes the object passed in obj into the specified fileName.

Definition

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

Parameters

fileName  String
Name of the file to create for serialization.
obj  Object
The Object to serialize.
options  XmlSerializationOptions  (Optional)
Options for serialization. This parameter is optional.
Default value: CompactSerializationOfPrimitiveArrays, EscapeNewlineCharacters

Exceptions

ArgumentNullExceptionfileName must not be null.
IOExceptionFile cannot be created or write error.
NotSupportedExceptionSerialization is not supported with provided options
ReflectionExceptionThe object hierarchy to serialize contains circular reference.

See Also