• C#数组实例


    /*
      Example10_8.cs illustrates the use of
      a three-dimensional rectangular array
    */
    
    using System;
    
    class Example10_8
    {
    
      public static void Main()
      {
    
        // create the galaxy array
        int[,,] galaxy = new int [10, 5, 3];
    
        // set two galaxy array elements to the star's brightness
        galaxy[1, 3, 2] = 3;
        galaxy[4, 1, 2] = 9;
    
        // display the Rank and Length properties of the galaxy array
        Console.WriteLine("galaxy.Rank (number of dimensions) = " + galaxy.Rank);
        Console.WriteLine("galaxy.Length (number of elements) = " + galaxy.Length);
    
        // display the galaxy array elements, but only display elements that
        // have actually been set to a value (or "contain stars")
        for (int x = 0; x < galaxy.GetLength(0); x++)
        {
          for (int y = 0; y < galaxy.GetLength(1); y++)
          {
            for (int z = 0; z < galaxy.GetLength(2); z++)
            {
              if (galaxy[x, y, z] != 0)
              {
                Console.WriteLine("galaxy[" + x + ", " + y + ", " + z +"] = " +
                  galaxy[x, y, z]);
              }
            }
          }
        }
    
      }
    
    }
    
  • 相关阅读:
    protobuf配置与使用
    gvim配置
    html div+css做页面布局
    php info
    开源相关工具汇总
    mem 0908
    linux dd指令
    java面试(2)--大数据相关
    Java基础面试题(1)
    转自ruby迷: 使用Net::SSH和Net::SCP编写Linux服务器管理脚本
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2038272.html
Copyright © 2020-2023  润新知