Set of extensions used for Adding, Subtracting, Multiplying, and Dividing two sequences.

Add two arrays:

  int[] arr1 = new int[] { 1, 2, 3, 4 };
  int[] arr2 = new int[] { 5, 6, 7, 8 };

  int[] res = arr1.Add(arr2).ToArray();   // 6, 8, 10, 12

Subtract two arrays:

  int[] arr1 = new int[] { 5, 6, 7, 8 };
  int[] arr2 = new int[] { 4, 3, 2, 1 };

  int[] res = arr1.Subtract(arr2).ToArray();   // 1, 3, 5, 7

Multiply two arrays:

  int[] arr1 = new int[] { 5, 6, 7, 8 };
  int[] arr2 = new int[] { 4, 3, 2, 1 };

  int[] res = arr1.Multiply(arr2).ToArray();   // 20, 18, 14, 8

Divide two arrays:

  double[] arr1 = new double[] { 5, 6, 7, 8 };
  double[] arr2 = new double[] { 4, 3, 2, 1 };

  double[] res = arr1.Divide(arr2).ToArray();   // 1.25, 2.0, 3.5, 8.0

Last edited Aug 9, 2011 at 3:48 PM by AmirLiberman, version 3

Comments

No comments yet.