We can't tell you how to fix this: it depends on a number of factors, such as what type your S3 array returns, and what the resulting string contains prior to conversion.
So change your code slightly for testing:
string sd1 = S3[1].ToString();
double dd1 = Convert.ToDouble(sd1);
string sd2 = S3[0].ToString();
double dd2 = Convert.ToDouble(sd2);
Pointk pt1 = new Pointk(dd1, dd2);
Then run your code in the debugger. When the exception happens, use the debugger to look at the content of the intermediate variables and work out exactly what you are trying to convert.
If should be fairly obvious from that why one of the conversions is failing.
But we can't do that for you - we don't have your data!
how to convert this string to double "-97.08215655572718"
Well...
string sd1 = "-97.08215655572718";
double dd1 = Convert.ToDouble(sd1);
Works fine for me!
But I don't like Convert.ToAnything - it's generally a lot better to use the relevant TryParse method and report or log problems rather than just let your app crash.
So i'd write your code as:
string sd1 = S3[1].ToString();
double dd1;
if (!double.TryParse(sd1, out dd1))
{
return;
}
Or more likely I'd see exactly what was in my array to start with and avoid strings altogether unless I really, really had to. I keep values in "native" form as much as possible, and cast where I have to rather than rely on string conversions.