I have a problem : I have a string containing values and I want to split them into a double array .
The input : 0.0 0.0 0.0
I have two ways but both are not working
First :
Dim arrString As String() = line.Split(New Char() {" "c})
Dim numbers As Double() = New Double(arrString.Length) {}
Dim i As Integer = 0
While i < arrString.Length
numbers(i) = Convert.ToDouble(arrString(i))
i += 1
End While
Second :
Dim nums As String() = line.Split(" "c)
Dim numbers As Double() = From num In nums Select Convert.ToDouble(num)
I get a FormatExeption exeption
Please help me , its for an .obj loader
The current culture is likely using a different decimal separator. Use the overload of the
ToDoublethat takes a format provider:(The
InvariantCultureproperty returns a neutral culture info that is based on english settings, so it uses period as decimal separator.)