4 개의 요소가 포함 된 문자열 배열이 있습니다. 어떤 모습일까요?문자열을 double로 변환합니다.
어떻게 지금까지이 작업을 수행 할 때 :
Vector newVector = new Vector(
(float)Convert.ToDouble(words[1]),
(float)Convert.ToDouble(words[2]));
나는 다음과 같은 오류 얻을 :
'Input string was not in a correct format.'
을 그리고 값이 '를 사용하기 때문에 그것 때문에 즉. ' 하지만 수동으로 ','작동하도록 배열을 변경하면 작동합니다. 어떻게하면 '모두 교체 할 수 있습니까?' ','. 사용
//(float)Convert.ToDouble(words[1]),
(float)Convert.ToDouble(words[1], CultureInfo.InvariantCulture),
사용'String.Replace' 또는 다른 지역 setings. – BWA
왜'float' 형변환을 사용하고 싶습니까? – Boggartfly
'Array.ConvertAll (words.Split (','), Double.Parse); ' 문자열 배열을 double 배열로 변환합니다. 사실 나는 다른 [SO] [1] 질문에서 이것을 얻었다. 나는 이것이 당신의 문제를 해결하기를 바랍니다. [1] : http://stackoverflow.com/questions/9524682/fastest-way-to-convert-string-array-to-double-array – Boggartfly