Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int[,] twoDArray = new int[3, 3];

            int[] arraySize = new int[twoDArray.Rank];

            for (int i = 0; i < arraySize.Length; i++)
            {
                arraySize[i] = twoDArray.GetUpperBound(i) + 1;
            }

            WorkWithElement workWithElement = null;

            WorkWithArray(twoDArray, arraySize, workWithElement = AssignValElem);

            WorkWithArray(twoDArray, arraySize, workWithElement = WriteValElem);

            Console.WriteLine();

            WorkWithArray(twoDArray, arraySize, workWithElement = CalculetSum);

            Console.WriteLine(sum);

            Console.ReadKey();
        }
Exemplo n.º 2
0
 static void WorkWithArray(int [,] twoArray, int [] arraySize, WorkWithElement workWithElement)
 {
     for (int x = 0; x < arraySize[0]; x++)
     {
         for (int y = 0; y < arraySize[1]; y++)
         {
             workWithElement(twoArray, x, y);
         }
         if (workWithElement == WriteValElem)
         {
             Console.WriteLine();
         }
     }
 }