'C# does not convert Number with int.TryParse [closed]

this is my code, I'm currently running in Processing. I'm receiving angle values in degrees.

string dataString = serialPort.ReadLine();
var dataBlocks = dataString.Split(',');
if (dataBlocks.Length < 3)
{
  Debug.LogWarning("Invalid data received");
  return; 
}

int angleX, angleY, angleZ;
if (!int.TryParse(dataBlocks[0], out angleX))
{
   Debug.LogWarning("Failed to parse angleX. RawData: " + dataBlocks[0]);
   return;
}

TryParse fails to parse the angle.

"Failed to parse angleX. RawData: 174.0"

As you can see, the raw data that was transmitted over the serial interface was 174.0.

And I cannot figure out why it does not parse the String into an integer.

Any ideas why this could be?

Possibly has to do with the dot instead of a comma?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source