Thursday, 15 October 2015

Retrieve Data from Single Dimensional array using for loop through LowerBound and UpperBound in C#

using System;
class Program
{
    static void Main()
    {
        int[] testArray = new int[5];
        testArray[0] = 10;
        testArray[1] = 20;
        testArray[3] = 40;
        for (int i = testArray.GetLowerBound(0); i <= testArray.GetUpperBound(0); i++)
        {
            Console.Write(testArray[i] + "\t");
        }
        Console.WriteLine("\n");
    }
}

No comments:

Post a Comment