Two dimensional indexer : Indexer : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Indexer »

 

Two dimensional indexer








    
 
using System;

class MultiplicationTable {
    private int[,] MultiplicationArray = new int[10, 10];

    public int this[int x, int y] {
        get {
            return MultiplicationArray[x, y];
        }
        set {
            MultiplicationArray[x, y] = value;
        }
    }
    public MultiplicationTable() {
        for (int i = 0; i < 10; i++) {
            for (int y = 0; y < 10; y++) {
                MultiplicationArray[i, y] = i * y;
            }
        }
    }
}

class MultiplicationTableClient {
    public static void Main(String[] args) {
        MultiplicationTable MyTable = new MultiplicationTable();
        Console.Write("3 x 9 is " + MyTable[3, 9]);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Indexer