Allocate a 2D array of doubles. - CSharp System

CSharp examples for System:Array Dimension

Description

Allocate a 2D array of doubles.

Demo Code

// Licensed under the Apache License, Version 2.0 (the "License");
using System.Collections.Generic;
using System;//from  w  w w  .  ja va2 s .  co  m

public class Main{
        /// <summary>
        /// Allocate a 2D array of doubles.
        /// </summary>
        /// <param name="rows">The number of rows.</param>
        /// <param name="cols">The number of columns.</param>
        /// <returns>The array.</returns>
        public static double[][] AllocateDouble2D(int rows, int cols)
        {
            var result = new double[rows][];
            for (int i = 0; i < rows; i++)
            {
                result[i] = new double[cols];
            }
            return result;
        }
}

Related Tutorials