What types of arrays are in C #

Source: Internet
Author: User

One-dimensional array (single-dimensional)
Multidimensional Arrays (Multidimensional)
Jagged Array (jagged arrays): A jagged array is an array of elements. The dimensions and sizes of jagged array elements can vary. Jagged arrays are sometimes referred to as "arrays of arrays." The following example shows how to declare, initialize, and access a jagged array.

The following declares a one-dimensional array of three elements, each of which is a one-dimensional array of integers:

C#
int[][] Jaggedarray = new int[3][];

You must initialize the Jaggedarray element before you can use it. You can initialize the element as shown in the following example:

C#
Jaggedarray[0] = new Int[5];jaggedarray[1] = new Int[4];jaggedarray[2] = new INT[2];

Each element is an array of one-dimensional integers. The first element is an array of 5 integers, the second one is an array of 4 integers, and the third is an array of 2 integers.

You can also use initializers to populate array elements with values, in which case the array size is not required. For example:

C#
Jaggedarray[0] = new int[] {1, 3, 5, 7, 9};jaggedarray[1] = new int[] {0, 2, 4, 6};jaggedarray[2] = new int[] {11, 22 };

What types of arrays are in C #

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.