I created a GUI and the ValueBox.Text is the string “randomstring”. What I want to do is:
if the ValueBox.Text has numbers only double valueLenght = Convert.ToDouble(ValueBox.Text); else if it has characters && numbers or only characters, then I thought that from MSDN that Convert.ToDouble(string) would return 0. Which is not the case here. The code goes to :
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
Then gives an exception from mscorlib
Convert.ToDoublethrows an exception if it cannot convert a string to a number.You likely want to try
Double.TryParse. The return value will betrueif the conversion succeeded, andfalseif not. Theout doubleparameter receives the result.