Question

In vb.net, is it possible to initialize, set, and Return a Structure inline?

If I have this Structure

Structure CopyAndPasteUniquesAndExistenceStructure
    Dim duplicatePoints As List(Of Array)
    Dim inexistentPoints As List(Of Array)
    Dim insertedRows As List(Of Object)
End Structure

How can I do this pseudo?

Return New CopyAndPasteUniquesAndExistenceStructure...
Était-ce utile?

La solution

Return New CopyAndPasteUniquesAndExistenceStructure With {.duplicatePoints = New List(Of Array), .inexistentPoints = New List(Of Array), .insertedRows = New List(Of Object)}

Or you can add a specialized constructor. This is useful if you want to validate the input, or if you want to make the lists read-only (which usually makes a lot of sense for lists).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top