XmlSerializerSerialize(Object, XmlSerializationOptions) Method

Serializes the object passed in obj parameter into a new XElement object.

Definition

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

Parameters

obj  Object
The object to serialize.
options  XmlSerializationOptions  (Optional)
Options for serialization. This parameter is optional.
Default value: CompactSerializationOfPrimitiveArrays, EscapeNewlineCharacters

Return Value

XElement
An XElement instance that contains the serialized object. Result can be deserialized by Deserialize(XElement) method.

Exceptions

NotSupportedExceptionRoot object is a read-only collection.
ReflectionExceptionThe object hierarchy to serialize contains circular reference.
-or-
Serialization is not supported with provided options

See Also