Actuellement, j'essaie de porter du code VB.NET en C#.Problème lors du portage du code VB.NET en C#
Le struct ressemble à ceci dans 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 du 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;
}
}
Pourquoi dois-je jeter les valeurs de retour pour flotter & int? Dans la version vb je n'ai pas à ..
Merci à tous.
C'est une méthode dans une structure, voir le bas du code ajouté par l'OP. – marcc
Sérieusement, je ne sais pas comment je pourrais rater quelque chose comme ça. J'ai honte de moi, merci beaucoup! –
Cependant, qu'en est-il de la question de la distribution? –