|
|
Title | Copy a two-dimensional array in Visual Basic .NET |
Description | This example shows how to copy a two-dimensional array in Visual Basic .NET. |
Keywords | copy two-dimensional array, copy 2-D array, two-dimensional arrays, 2-D arrays, example, example program, Windows Forms programming, Visual Basic .NET, VB.NET |
Categories | Software Engineering |
|
|
The Array class's Copy method can copy items from one array to another. This example uses the following code to copy the values in the Values array into a new array.
|
|
Dim new_values(Values.GetUpperBound(0), _
Values.GetUpperBound(1)) As String
Array.Copy(Values, new_values, Values.Length)
|
|
This code makes a new array with the same dimensions as the original one. It then uses Array.Copy to copy the items from the original array to the new one.
The example contains additional code to display the arrays but it's not important for making the copy so it isn't shown here. Download the example to see how it works.
|
|
|
|
|
|
|
|
|