0

convert.todouble and console.readline

if I write this double age = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("You are {0} years old", age); and I enter 4.4 it writes 4.4. if I write 4,4 it writes 44. why does this happen?

22nd Aug 2016, 11:25 AM
Desy Mimi
Desy Mimi - avatar
4 odpowiedzi
+ 1
in Europe we use comma for floating point numbers. so I made a typo by writing 4,4 as an input. I just would like to know why it ignored the comma and it didn't report an error like when I type a character instead of a float
22nd Aug 2016, 11:40 AM
Desy Mimi
Desy Mimi - avatar
+ 1
Ahh, it's because the Convert.ToDouble() function already expects a string input with a group separator (,) which it simply ignores. That thing, happens only for comma.
22nd Aug 2016, 2:47 PM
Erwin Mesias
Erwin Mesias - avatar
0
4,4? as in (four-comma-four)? or that was just a typographical error?
22nd Aug 2016, 11:29 AM
Erwin Mesias
Erwin Mesias - avatar
0
thank you
22nd Aug 2016, 8:23 PM
Desy Mimi
Desy Mimi - avatar