3 minutes read
Beim Versuch in einem XML Formular ein XML Attribute mit einem nullable integer zu deserialisieren erhielt ich eine InvalidOperationException beim Erzeugen des XmlSerializers. Auf meiner Suche im Internet fand ich dann einen Beitrag, der auf die MSDN Referenz verwies:
"You cannot apply the IsNullable property to a member typed as a value type because a value type cannot contain null reference. Additionally, you cannot set this property to false for nullable value types. When such types are null reference, they will be serialized by setting xsi:nil to true."
Ich fand schlussendlich drei Optionen, die für mich in Frage kamen (wobei ich persönlich die 3 Variante inzwischen präferiere):