小编Ela*_*den的帖子

有没有办法在方法之间进行数学加法?

我想知道方法之间是否有任何方法可以进行数学加法?代码如下.

从Main :(我需要计算,但我不能在方法之间进行计算)

Ball.setPositionY = Ball.setPositionY + Ball.setSpeedY;
Run Code Online (Sandbox Code Playgroud)

来自一个班级:

public class Ball
    {
    public int speedX { get; set; }
    public int speedY { get; set; }
    public int positionX { get; set; }
    public int positionY { get; set; }

    public Ball(int speedX, int speedY, int positionX, int positionY)
    {
        this.speedX = speedX;
        this.speedY = speedY;
        this.positionX = positionX;
        this.positionY = positionY;
    }

    public void setSpeedX(int newSpeedX)
    {
        speedX = newSpeedX;
    }

    public void setSpeedY(int newSpeedY)
    {
        speedY = …
Run Code Online (Sandbox Code Playgroud)

.net c# methods

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

如何在C#中的许多变量中插入相同的值?

我有很多INT变量,blueBallVelocityX1,blueBallVelocityX2,blueBallVelocityX3,blueBallVelocityX4,blueBallVelocityX5,blueBallVelocityX6,blueBallVelocityX7,blueBallVelocityX8,blueBallVelocityX9,blueBallVelocityX10,blueBallVelocityX11,blueBallVelocityX12,blueBallVelocityX13,blueBallVelocityX14,blueBallVelocityX15,blueBallVelocityX16,blueBallVelocityX17,blueBallVelocityX18,blueBallVelocityX19,blueBallVelocityX20和blueBallVelocityY1(1- 20).我需要指定值为5的所有变量.我该怎么办?

c# variables

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

标签 统计

c# ×2

.net ×1

methods ×1

variables ×1