What kind of array is Foo() as Foo()?
We generated a class from an XML file a while back. I think we used xsd.exe.
One of the main node collections in the XML file was rendered as:
<System.Xml.Serialization.XmlElementAttribute("PRODUCT")> _ Public Property PRODUCT() As PRODUCT() Get Return Me.pRODUCTField End Get Set Me.pRODUCTField = value End Set End Property
And sure, there's PRODUCT class defined later on, and it worked fine. Serialized and deserialized fine. Didn't need to worry about it or manipulate it.
Only now we have to revisit and manipulate the data.
But what kind of collection (array?) is Public Property PRODUCT() As PRODUCT(), and how do we loop over it? And add to it?
Basic question, I know. Probably got too comfortable with generics and now xsd has thrown something at me which isn't List(of T) I'm running scared.
Don't be confused by the two sets of parens there. The first set, is simply the parens after the name of the property, whereas the second identifies the return type as an array of Product objects.
Similar to: Public Property IDs() As Integer()
That property returns only an array of integers, and the parens near IDs() only exist because you're declaring the property.
Since it appears to be a standard array of Product objects, you can loop over it with any number of normal loops:
For Each p As PRODUCT In obj.PRODUCTS() ... Next
For i As Integer = 0 To obj.PRODUCTS.Length-1 ... Next i
Public Property PRODUCT() as PRODUCT()
Returns an array of Objects Of Type PRODUCT. Now whether that Type is a Collection, Structure, or Array I do not know with the code you have provided. The simplest way to loop over it would be as such.
For each prod as PRODUCT in rtnPRODUCTS 'Do Something Next