Array lowerbound and upperbound

In this chapter you will learn:

  1. Get lowerbound and upperbound

Get lowerbound and upperbound

using System;/*from   j  av  a  2  s  .  co m*/

public class MainClass
{
    static void Main() {
        int[,] twoDim = { {1, 2, 3},
                          {4, 5, 6},
                          {7, 8, 9} };

        for( int i = twoDim.GetLowerBound(0);i <= twoDim.GetUpperBound(0);++i ) {
            for( int j = twoDim.GetLowerBound(1);j <= twoDim.GetUpperBound(1);++j ) {
                Console.WriteLine( twoDim[i,j] );
            }
        }
    }
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. How to sort an array
  2. Sort an array and search for a value
  3. Implementing IComparable and sort by Array.Sort
  4. Array.Sort by CultureInfo
Home » C# Tutorial » Array
Array
Array loop
Array dimension
Jagged Array
Array length
Array Index
Array rank
Array foreach loop
Array ForEach Action
Array lowerbound and upperbound
Array Sort
Array search with IndexOf methods
Array binary search
Array copy
Array clone
Array reverse
Array ConvertAll action
Array Find
Array SequenceEqual