分享

C#数组定义例子

 離開╭ァ會沉淪 2011-03-06
using System;
    class DeclareArrayaSample
    {
        public static void Main()
         {
 
//一维数组
      int[] numbers=new int[5];
//多维数组
      string[,] names= new string[5,4];
//不规则数组
      byte[][] scores=new byte[5][];
//创建不规则数组
      for(int i=0;i<scores.Lenghth;i++)
         {
                scores[i]=new byte[i+3];
         }
//打印每一行的长度
        for(int i=0;i<scores.Length;i++)
       {
           Console.WriteLine("Length of row{0} is {1}",i,scores[i].Length);
 
          }
     }
}
这个例子的输出是:
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
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约