C # Array

Source: Internet
Author: User
When declaring an array, add a pair of brackets after the variable type of each element.
Int [] intergers;
To initialize an array of a specific size, you can use the new keyword to specify the size in square brackets after the type.
Int [] integers = new int [2]
It can also be declared without initialization, And the size will be dynamically specified later.
Int [] integers;
Integers = new int [32];
When initializing an array, you cannot use variables to set how many elements the array should contain. However, you can declare a constant for the array length:
Const int Len = 3;
String [] strings = new string [Len];

You can use length to determine the array size.
Int arraylength = intergers. Length
Array. Sort (string) array in the forward order
Array. Reverse in reverse order

C # multi-dimensional array
C # supports two arrays. The first is a rectangular array.
String [,] strings;
C # The second supported multi-dimensional array is an orthogonal array.
Int [] [] A = new int [3] [];
A [0] = new int [4];
A [1] = new int [2];
A [2] = new int [1];
To declare an orthogonal 3D array, use
Int [] [] [] ints;

Aboat class
If methods do not attempt to access instance data or other instance methods, they can be declared as static.
If you do not want fields generated for each instantiation class to be declared as static
Non-static fields cannot be referenced for static classes.

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.