Well yes.
What you are doing is this:
int total = 0;
for (int i = 1; i < 10; i++)
{
total = i;
}
Console.WriteLine(total);
And you are surprised when the result is always "9".
Of course it is: you overwrite the value of
total
each time you go round the loop.
What you need to do is:
int total = 0;
for (int i = 1; i < 10; i++)
{
total += i;
}
Console.WriteLine(total);
And you will get the sum.
But you don't need to be so complicated!
culture = CultureInfo.CreateSpecificCulture("dk-DK");
NumberStyles style = NumberStyles.Number;
double number;
double total = 0.0;
foreach (string value in values)
{
if (Double.TryParse(value, style, culture, out number))
{
total += Number;
}
}
litSum.Text = total.ToString();