Search code examples
c#double

Read textbox in to a double without Percent


my question is i write a textbox with a double in Percentage but after i read this textbox and i put this in other double but how ?

 Actuallyday24.Text = day25oee24d.ToString("P2");
 double Gridactually24    = double.Parse(Actuallyday24.Text);

what is my mistake ?


Solution

  • try like this .

    also u can find this with easy research :

    How to convert percentage string to double?

     value = value.Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.PercentSymbol, "");
    

    Example

    textBox2.Text = "15%";
    
        var K = textBox2.Text;
    
        K = K.Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.PercentSymbol, "");
    
        double test = Convert.ToDouble(K);