c# - Cannot convert a string array position(2.6) in double new double array -
i have string array have different types of symbols. divided separate elements, , 1 of them 2.6
. want him convert, gives me error, tried different methods , written me:
input string not in correct format.
string s = console.readline(); // input "apr\2.6\7\300"; string[] array = s.split('\\'); // array separeted: apr 2.6 7 300 double[] num = new double[3]; num[0] = double.parse(intarray[1]); // me convert ! :)
it seems current culture has different decimal separator.
you can specify invariant culture parsing, has period decimal separator:
num[0] = double.parse(array[1], cultureinfo.invariantculture);
Comments
Post a Comment