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
  • 15,313
  • 25
  • 73
  • 114

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
  • 489,969
  • 99
  • 883
  • 1,009