Create Array With Bounds : Array CreateInstance « Data Structure « C# / CSharp Tutorial






using System;

    public  class MainClass 
    {
        static void Main()
        {
            int[] lengthsArray = new int[2] { 3, 5 };
            int[] boundsArray = new int[2] { 2, 3 };
            Array multiDimensionalArray = Array.CreateInstance(typeof(String), lengthsArray, boundsArray);
            for  (int i = 0; i < multiDimensionalArray.Rank; i++)
                Console.WriteLine("{0}:\t{1}\t{2}", i,multiDimensionalArray.GetLowerBound(i),multiDimensionalArray.GetUpperBound(i));
        }
    }








11.13.Array CreateInstance
11.13.1.Dynamic array creation
11.13.2.Use Array.CreateInstance to create array instance
11.13.3.Create Array With Bounds