Well a is just not an integer value - you could use Convert.ToDouble() instead. To guard against parsing errors in case that is a possibility use double.TryParse() instead:
string a = "11.4";
double d;
if (double.TryParse(a, out d))
{
//d now contains the double value
}
Edit:
Taking the comments into account, of course it is always best to specify the culture settings. Here an example using culture-indepenent settings with double.TryParse() which would result in 11.4 as result:
if (double.TryParse(a, NumberStyles.Number, CultureInfo.InvariantCulture, out d))
{
//d now contains the double value
}
4
JXITC
On
A very first glance, the number literal "11.4" is not a actual "int". Try some other converting format, such as ToDouble()
I have tried following code in C# for your reference.
string a = "11.4";
double num_a = Convert.ToDouble(a);
int b = 2;
double ans = num_a * b;
Well
a
is just not an integer value - you could useConvert.ToDouble()
instead. To guard against parsing errors in case that is a possibility usedouble.TryParse()
instead:Edit:
Taking the comments into account, of course it is always best to specify the culture settings. Here an example using culture-indepenent settings with
double.TryParse()
which would result in11.4
as result: