diff --git a/MBS.Framework/MathExtensions.cs b/MBS.Framework/MathExtensions.cs index 1a6a5bc..94d99d7 100644 --- a/MBS.Framework/MathExtensions.cs +++ b/MBS.Framework/MathExtensions.cs @@ -36,5 +36,20 @@ namespace MBS.Framework { return (long)((random.NextDouble() * (maxValue - minValue)) + minValue); } + + /// + /// Calculates the sum of all elements in the array. + /// + /// The sum of all elements in the array. + /// The array to sum. + public static ushort Sum(this ushort[] array) + { + ushort value = 0; + for (int i = 0; i < array.Length; i++) + { + value += array[i]; + } + return value; + } } }