How to set character used as decimal point in C #?

I am making a quick program in C # and I have a problem with a character that is used as a decimal point. Right now i need to use

but I want to be able to use

.

or even better, both.

I am looking for a short and simple solution, because the whole program is a hack, and I doubt that, with the exception of this point, I will ever need to make it look better.

Here is one of the problematic parts of the code:

private void button2_Click(object sender, EventArgs e)
        {
            double Ri, B, R, T;            
            Ri = Convert.ToDouble(textBox2.Text);
            B = Convert.ToDouble(textBox3.Text);
            R = Convert.ToDouble(textBox6.Text);

            T = B / Math.Log(R*1000 / Ri, Math.Exp(1)) - 273.15;
            textBox5.Text = T.ToString();

        }

, , . , Convert.ToDouble . ? , , .

, , .

+3
2

:

textBox5.Text = T.ToString(CultureInfo.GetCultureInfo("de-DE").NumberFormat);

:

textBox5.Text = T.ToString(CultureInfo.InvariantCulture.NumberFormat); 
// or use any "normal" country

( ), :

double d = double.Parse(textBox5.Text, CultureInfo.GetCultureInfo("de-DE").NumberFormat);

:

double d = double.Parse(textBox5.Text, CultureInfo.InvariantCulture.NumberFormat);
+3
        float Ri, B, R, T;
        Ri = float.Parse((String.Format("{0:0.00}",textBox2.Text)));
        B = float.Parse((String.Format("{0:0.00}",textBox3.Text))));
        R = float.Parse((String.Format("{0:0.00}", textBox6.Text)));

        T = B / Math.Log(R * 1000 / Ri, Math.Exp(1)) - 273.15;
        textBox5.Text = String.Format("{0:0.00}",T);
0

Source: https://habr.com/ru/post/1786293/


All Articles