I write a method to convert the string into double,here is the code

```
public double convertToDouble(string number)
{
    string temp = number;
    if (number.Contains("x"))
    {
        int locationE = number.IndexOf("x");
        string exponent = number.Substring(locationE + 5, number.Length - (locationE + 5));
        temp = number.Substring(0, locationE - 1) + "E" + exponent;
    }

    return Convert.ToDouble(temp);
}

```

But if the temp variable passed in as null or empty string, the conversion will fail. How could i write this part.