Introduction to C # arrays

Source: Internet
Author: User

First, the definition of the array

Array: is a data structure that contains several variables that can be accessed through an index.

Elements of an array: Variables in an array are called elements of an array.

Element type: The element in the array has the same data type, which is called the element type of the array.

Dimension of an array: refers to the number of indexes associated with each array element.

One-dimensional arrays: An array of dimension 1 is called a one-dimensional array. Such as:

Int[] Array; a two-dimensional array: An array of Dimension 2 is called a two-dimensional array.

Three-dimensional array: An array of Dimension 3 is called a three-dimensional array.

A multidimensional array: Also known as a rectangular array, is an array of dimensions greater than 1. These include two-dimensional arrays, three-dimensional arrays, and so on. Such as:

string[,] array; a jagged array, also known as an array of arrays, is an array of elements in an exponential group. The dimensions and sizes of jagged array elements can vary. Such as:

Byte[][] scores; arrays can be used either to store value types or to store reference types.

Second, the length of the array

The length of each dimension in the array is an integer greater than or equal to zero. The length of the array is specified when the instance is created.

The length of the dimension determines the extent of the subscript of the dimension, and if the dimension is of length n, the subscript range of the dimension is 0 to N-1.

The product of the length of each dimension in an array is the total number of elements of the array. If the length of one or more dimensions of an array is zero, the array is said to be empty.

Iii. Indexing of arrays

The index of the C # array starts from zero. If there is an array of n elements, it is indexed from 0 to n-1.

Iv. properties of an array

The default value for array elements of numeric types is zero, and the default value for an array element of a reference type is null.

The elements of a jagged array are reference types and are initialized to null.

An array element can be of any type, including the array type.

An array type is a reference type derived from an abstract base type array.

Five, tips

An array accesses the value of its member variable through an index, and the array in C # can store all object types.

Introduction to C # arrays

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.