基本类型--数组

131数组的类型转换

132所有数组都隐式继承自System.Array

133所有数组都隐式实现IEnumerableICollectionIlist

134数组的传递与返回

135创建下界非0的数组

public sealed class DynamicArrays {
        
public static void Main() {
            
//创建这样一个数组[20052009][14]
            Int32[] lowerBounds =20051 };//第二维大小
            Int32[] lengths =54 };//第一维大小
            Decimal[,] quarterlyRevenue = (Decimal[,])
              Array.CreateInstance(
typeof(Decimal),lengths,lowerBounds);
            Console.WriteLine(
"{0,4}{1,9}{2,9}{3,9}{4,9}""Year""Q1""Q2""Q3""Q4");
            Int32 firstyear 
= quarterlyRevenue.GetLowerBound(0);//2005
            Int32 lastyear = quarterlyRevenue.GetUpperBound(0);//2009
            Int32 firstQuarter = quarterlyRevenue.GetLowerBound(1);//1
            Int32 lastQuarter = quarterlyRevenue.GetUpperBound(1);//4
            for (Int32 y = firstyear; y <= lastyear; y++)
            
{
                Console.WriteLine(y 
+ " ");
                
for (Int32 q = firstQuarter; q <= lastQuarter; q++)
                    Console.Write(
"{0,9:C}", quarterlyRevenue[y, q]);
                Console.WriteLine();
            }

            Console.ReadLine();

        }

    }
136数组访问性能
posted @ 2008-05-21 17:49  青羽  阅读(583)  评论(0编辑  收藏  举报