Performs addition on two arrays - CSharp System

CSharp examples for System:Array Calculation

Description

Performs addition on two arrays

Demo Code


using System.Linq;
using System.Collections.Generic;
using System;/*from ww  w  . ja v  a2  s .co m*/

public class Main{
        /// <summary>
        /// Performs addition on two arrays
        /// </summary>
        /// <returns></returns>
        public static double[] ArrayAdd(this double[] array1, double[] array2)
        {
            var newArray = new double[array1.Length];
            for (int i = 0; i < array1.Length; i++)
            {
                newArray[i] = array1[i] + array2[i];
            }
            return newArray;
        }
}

Related Tutorials