E
E
ekdown2014-06-26 20:16:28
C++ / C#
ekdown, 2014-06-26 20:16:28

How to extract number with dot from textbox?

Good evening!
Such problem:
from textbox'a value is taken out and written down in a variable.
double x = double.Parse(TextBox1.Text);
But as soon as I enter the number
0.5 into the textbox, everything crashes with an error.
How do I still extract numbers of this type?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
barkalov, 2014-06-26
@ekdown

Either just:
Or difficult :

double = double.Parse(TextBox1.Text, CultureInfo.GetCultureInfo("ru-RU").NumberFormat);

A
AlexP11223, 2014-06-26
@AlexP11223

Better something like this:
If you simply replace the dot with a comma, it will not work for those who have a dot set in the OS.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question