2
Answers

XML attribute issue during deserialize

Photo of George George

George George

16y
6.8k
1

Hello everyone,

I am using xsd to generate a C# class from an XML file. I noticed there are a couple of fields of the generated classes are marked with various XML attribute, like XML attribute and XML element.

Now I want to add more restrictions to the input XML file during deserialization,

- Make some fields in the C# class not nullable during serialization;

- Make some fields to accept only numbers (currently the automatic generated C# file is using string type other than number type to represent the fields).

Any ideas about how to decorate the generated C# class file to achieve the goal?

thanks in advance,
George

Answers (2)