Hi,
Currently I am trying to port some VB.NET code to C#.
The struct looks like this in VB.NET:
Public Structure sPos
Dim x, y, z As Single
Function getSectorY() As Single
Return Math.Floor(y / 192 + 92)
End Function
Function getSectorX() As Single
Return Math.Floor(x / 192 + 135)
End Function
Function getSectorXOffset() As Int32
Return ((x / 192) - getSectorX() + 135) * 192 * 10
End Function
Function getSectorYOffset() As Int32
Return ((y / 192) - getSectorY() + 92) * 192 * 10
End Function
End Structure
C# Version of the struct:
public struct sPos
{
public float x;
public float y;
public float z;
public float getSectorY()
{
return (float)Math.Floor(y / 192 + 92);
}
public float getSectorX()
{
return (float)Math.Floor(x / 192 + 135);
}
public Int32 getSectorXOffset()
{
return (int)((x / 192) - getSectorX() + 135) * 192 * 10;
}
public Int32 getSectorYOffset()
{
return (int)((y / 192) - getSectorY() + 92) * 192 * 10;
}
}
Why do I have to cast the return values to float & int ? In the vb version I don't have to..
Thanks everyone.