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...
有帮助吗?

解决方案

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top