2

Question: How to shorten this array creation ?
I need to create an array of type ReportingService2005_WebService.Property with one property.

Something like:

Dim PropertyArray() as new  ReportingService2005_WebService.Property(1)

I have to do this:

        Dim PropertyArray As ReportingService2005_WebService.Property() = New ReportingService2005_WebService.Property(0) {}
        PropertyArray(0) = New ReportingService2005_WebService.Property
        PropertyArray(0).Name = "Description"
        PropertyArray(0).Value = "Automatically added DataSource"

1 Answer 1

3

http://blogs.msdn.com/b/wriju/archive/2008/02/05/vb-net-9-0-object-and-array-initializers.aspx

Dim PropertyArray() As ReportingService2005_WebService.Property = { _
    new ReportingService2005_WebService.Property() With {.Name = "Description", .Value="Automatically added DataSource" } _
}

Make sure your "array brackets" are in the correct place in the initial Dim statement. Should be: Dim PropertyArray()...

Sign up to request clarification or add additional context in comments.

2 Comments

what version of VB.NET is required? E.g. would it work with the version of VB.NET corresponding to Visual Studio 2008?
as per that link in my post it is VB.NET v9, which is VS2008.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.