Reputation: 115
I don't know much about C#, but I was trying to do a simple division here and I think I'm going mad, because nothing works.
Ok, so explain to me why this works:
double minimum = 2.00 / 100.00;
Console.WriteLine(minimum); // displays "0,02"
But this doesn't work?:
double result;
if(Double.TryParse(returnTextBox.Text, out result))
{
double minimum = (double)result / 100.00;
Console.WriteLine(minimum); // displays "2"
}
I tried casting (double) on everything possible. Also without casting it. Seems to always show 2. I feel like im missing something important, I just can't see it.
Upvotes: 0
Views: 91
Reputation: 115
The solution was this:
Double.TryParse(returnTextBox.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out result)
Thanks everyone!
Upvotes: 1