小编try*_*git的帖子

为什么这段代码会返回不同的值?(C#和VB.NET)

VB.NET代码:

Module Module1

Sub Main()
    Dim x, y As Single
    x = 0 + (512 / 2 - 407) / 256 * 192 * -1
    y = 0 + (512 / 2 - 474) / 256 * 192
    Console.WriteLine(x.ToString + ": " + y.ToString)
    Console.ReadLine()
End Sub

End Module
Run Code Online (Sandbox Code Playgroud)

返回:113,25:-163,5

C#代码:

class Program
{
    static void Main(string[] args)
    {
        float x, y;
        x = 0 + (512 / 2 - 407) / 256 * 192 * -1;
        y = 0 …
Run Code Online (Sandbox Code Playgroud)

c# vb.net

10
推荐指数
2
解决办法
233
查看次数

C#运算符'/'不能应用于'方法组'和'int类型的操作数

此行发生错误:

xPoint是Int32

randomsize是int

xPoint = pictureBox1.Width / 2 - randomsize -  objectPos.getOffset / 10 * randomsize / 192;         
Run Code Online (Sandbox Code Playgroud)

这是显然导致它的功能,有人能解释我为什么吗?

        public float getSector()
        {
            return (float)Math.Floor(x / 192 + 135);
        }

        public Int32 getOffset ()
        {
            return (Int32)((x / 192) - getSector() + 135) * 192 * 10;
        }
Run Code Online (Sandbox Code Playgroud)

c# operators

2
推荐指数
1
解决办法
5960
查看次数

标签 统计

c# ×2

operators ×1

vb.net ×1