Assigning Structures to Variables

Because structures are value types, assigning an instance of a structure to a variable declared as of that type creates a full copy of the data. The following brief code demonstrates this:

'Creates a real copy of firstOrderDim thirdOrder As OrderthirdOrder = firstOrder

In the preceding code, thirdOrder is a full copy of firstOrder. You can easily check this by using the DataTips feature of the Visual Studio Debugger or adding the variable to a Watch window.

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.