Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use VB.NET Multidimensional Array

Shulou Source: shulou.com Published: 2022-06-02 08:56:48 10月03日 Update

This article is about how to use VB.NET multidimensional arrays. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

VB.NET multi-dimensional array can be understood as "array of arrays", which has more "dimension" concept than one-dimensional array. Complex information can be recorded with multidimensional arrays. For example, in order to track every pixel on a computer screen, you need to reference its X and Y coordinates, and you should use a multi-dimensional array to store the value.

The declaration syntax for VB.NET multidimensional arrays is as follows:

Dim ArrayName (VarNumber1

VarNumber2,.,VarNumberN)

As Type

All the rules of one-dimensional array can be extended to multi-dimensional array above two dimensions. For example, the following statement declares a two-dimensional array of 10 × 10 and a three-dimensional array of 4 × 10 × 15:

Dim MatrixA (10) As Double Dim MultiD (4) 10) As Single

The total number of elements is the product of the dimensions of each dimension, that is, 100 and 600.

Note: when increasing the dimension of the array, the storage space occupied by the array will be greatly increased, so be careful with multi-dimensional arrays. Be more careful when using "Object" arrays, as they require more storage space. With loop operands, you can use "For" loop nesting to effectively deal with multi-dimensional arrays. For example, each element is assigned a value in "MatrixA" based on its position in the array:

Dim I,J As Integer

Dim MatrixA (10 and 10)

As Double

For iTunes 0 to 9

For Junior 0 to 9

MatrixA (iMagazine J) = Ifex 10J

Next

Next

Thank you for reading! This is the end of the article on "how to use VB.NET multidimensional arrays". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Array multidimensional storage element content more space article one-dimensional two-dimensional loop good complex practical efficient product location information pixels coordinates Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple OPPO Reno Shulou Information Docker