C# 2.0学习之--数组

编译与执行:
 
csc arrays.cs
            arrays




arrays.cs :

//Copyright (C) Microsoft Corporation.  All rights reserved.

// arrays.cs
using System;
class DeclareArraysSample
{
    public static void Main()
    {
        // Single-dimensional array
        int[] numbers = new int[5];

        // Multidimensional array
        string[,] names = new string[5,4];

        // Array-of-arrays (jagged array)
        byte[][] scores = new byte[5][];

        // Create the jagged array
        for (int i = 0; i < scores.Length; i++)
        {
            scores[i] = new byte[i+3];
        }

        // Print length of each row
        for (int i = 0; i < scores.Length; i++)
        {
            Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
        }
    }
}


 

转载于:https://www.cnblogs.com/llbofchina/archive/2006/06/23/434147.html

猜你喜欢

转载自blog.csdn.net/weixin_34236869/article/details/94206698
今日推荐