0

We need to specify a certain sort order for the fields of a class which is serialized to XML. I appreciate that it's not necessarily good practice to rely on sort order when dealing with XML elements but in our case there's a reason to do so.

So ... this answer for C# advises using XmlElementAttribute and I've translated the C# to VB as:

<System.Xml.Serialization.XmlElementAttribute(Order = 1)> _
Public Property Foo() As String
etcs

But it complains that Name 'Order 'is not declared. Have I mistranslated from C# or is there some other issue here?

Community
  • 1
  • 1
hawbsl
  • 14,484
  • 24
  • 72
  • 112

1 Answers1

3

The named property assignment syntax is incorrect and should be:

<System.Xml.Serialization.XmlElementAttribute(Order := 1)>

Note the extra : after the =. This is for named properties that are not part of a constructor.

Oded
  • 477,625
  • 97
  • 867
  • 998