# SUNWEN教程之----C#進階3

（三）
mrfat@china.com

int[] table; //不能寫成int table[]

int[] numbers; // 它的長度是任意的

int[10] numbers;//指定了一個長度為10的數組.

int[] numbers;

string[,] names;

byte[][] scores;

int[] numbers = new int[5];

string[,] names = new string[5,4];

byte[][] scores = new byte[5][];
for (int x = 0; x < scores.Length; x++)
{
scores[x] = new byte[4];
}

int[,,] buttons = new int[4,5,3];

int[][,,][,] numbers;

000: // Arrays\arrays.cs
001: using System;
002: class DeclareArraysSample
003: {
004:     public static void Main()
005:     {
006:         // Single-dimensional array
007:         int[] numbers = new int[5];
008:
009:         // Multidimensional array
010:         string[,] names = new string[5,4];
011:
012:         // Array-of-arrays (jagged array)
013:         byte[][] scores = new byte[5][];
014:
015:         // Create the jagged array
016:         for (int i = 0; i < scores.Length; i++)
017:         {
018:             scores[i] = new byte[i+3];
019:         }
020:
021:         // Print length of each row
022:         for (int i = 0; i < scores.Length; i++)
023:         {
024:             Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
025:         }
026:     }
027: }

Length of row 0 is 3
Length of row 1 is 4
Length of row 2 is 5
Length of row 3 is 6
Length of row 4 is 7

int[] numbers = new int[5] {1, 2, 3, 4, 5};
string[] names = new string[3] {"Matt", "Joanne", "Robert"};

int[] numbers = new int[] {1, 2, 3, 4, 5};
string[] names = new string[] {"Matt", "Joanne", "Robert"};

int[] numbers = {1, 2, 3, 4, 5};
string[] names = {"Matt", "Joanne", "Robert"};

int[] numbers = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
numbers[4] = 5;

int[,] numbers = { {1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10} };
numbers[1, 1] = 5;

int[] numbers = {1, 2, 3, 4, 5};
int LengthOfNumbers = numbers.Length;

## E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

## Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

## Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth \$300-1200 USD