public static int HighestProductOf3(int[] arrayOfInts)
int arrayCount = arrayOfInts.Length;
throw new System.ArgumentException("Highest Product of 3 requires minimum of 3 ints to evaluate!");
arrayOfInts = arrayOfInts.OrderBy(x => x).ToArray();
int maxProduct = arrayOfInts[arrayCount - 1] * arrayOfInts[arrayCount - 2] * arrayOfInts[arrayCount - 3];
if(arrayOfInts[0] < 0 && arrayOfInts[1] < 0 && arrayOfInts.Last() > 0)
maxProduct = Math.Max(maxProduct, arrayOfInts[0] * arrayOfInts[1] * arrayOfInts.Last());
public static void Main()
int maxProduct = HighestProductOf3(new int[] { -1, -2, -3, 10 });
Console.WriteLine(maxProduct);