Convert Percentage String to Double

Published on Tuesday, July 5, 2011
c#

If you have a percentage string and you want to convert it to a number type, like double. Here we have a sample:

string numString = myTextBox.Text.Replace(System.Globalization.CultureInfo.CurrentCulture.NumberFormat.PercentSymbol, "");
float fv = (float)(System.Convert.ToDouble(numString) / 100);