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()
        Return Me.pRODUCTField
    End Get
        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()


For i As Integer = 0 To obj.PRODUCTS.Length-1
Next i

Your code

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

Need Your Help

How to undo changes on JSpinner?

java undo jspinner

I need to validate the user input of a JSpinner, and if invalid, I need to undo (rollback) the value change. What is the best way to do it?

problem with masterpage and jquery

c# javascript asp.net jquery master-pages

I have a MasterPage that inside its content section I added a FORM element.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.