Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCopy a two-dimensional array in Visual Basic .NET
DescriptionThis example shows how to copy a two-dimensional array in Visual Basic .NET.
Keywordscopy two-dimensional array, copy 2-D array, two-dimensional arrays, 2-D arrays, example, example program, Windows Forms programming, Visual Basic .NET, VB.NET
CategoriesSoftware 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.

 
 
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated