Reputation: 529
I want to calculate some math in C#, but I have a problem. My numbers are all written with .
instead of ,
. For example 0.1 instead of 0,1.
(2^8 - 1)* 0.1 - 99.9
Because all of them are string, I convert them to int.
My code:
String factor = "0.1";
String offset = "99.9";
Int64 result = (Convert.ToInt64(Math.Pow(2, 8) - 1) * Convert.ToInt64(factor.ToString().Replace(".", ","))) + Convert.ToInt64(offset.ToString().Replace(".", ","));
I am getting an error: "String not correct format."
Upvotes: 0
Views: 86