Multidimensional array of vb.net

Source: Internet
Author: User
Tags arrays

Multidimensional arrays can be understood as "arrays of arrays", with more "dimension" concepts than one-dimensional arrays. You can use multidimensional arrays to record complex information. For example, to track every pixel on a computer screen, you need to reference its x, y coordinates, and you should store the values in a multidimensional array.
VB.net declares the syntax for multidimensional arrays as follows:
Dim arrayname (Varnumber1,varnumber2,......, varnumbern) as Type
You can extend all the rules of a one-dimensional array to more than two dimensions of multidimensional arrays. For example, the following statement declares a two-dimensional array of 10x10 and a three-dimensional array of 4x10x15:
Dim Matrixa (10,10) as Double
Dim Multid (4,10,15) as single
The total number of elements is the product of the dimensions of each dimension, that is, 100, 600.
Note: When you increase the number of dimensions in an array, the storage space occupied by the array increases dramatically, with all the multidimensional arrays to be used with caution. Use the "Object" array with extra care because they require more storage space. An array of loops can be nested with a "for" loop to efficiently process multidimensional arrays. For example, in "Matrixa", it assigns values based on the position of each element in the array:

Dim i,j As Integer
Dim Matrixa (10,10) as Double for
i=0 to 9 for j=0 to
    9
        Matrixa (i,j) =i*10+j
    >next

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.