public static void Main()
double[] prices = new double[8] { 55.39, 109.23, 48.29, 81.59, 81.58, 105.53, 94.45, 12.24 };
Console.WriteLine(MaxProfit(prices));
static string MaxProfit(double[] prices)
double max = double.MinValue;
double maxDiff = double.MinValue;
double bottom = prices[0];
for (int i = 1; i < prices.Length; i++)
diff += prices[i] - prices[i - 1];
return string.Format("Buy at {0}; Sell at {1}; Profit of ${2}", max - maxDiff, max, maxDiff);