小编Gua*_*ang的帖子

有没有办法避免在C#中编写重复的代码?

我想在表格中插入更多的球.但是,为了让它反弹,我必须为不同的球反复编码相同的算法.我是否知道如果不一遍又一遍地写它,我有什么办法可以做到的?我的代码如下.

int bBA1; //The x axis from the upper left corner
int bBA2; //The y axis from the upper left corner 
int spdBBA1; //The change of x
int spdBBA2; //The change of y

public StartGame()
{
    InitializeComponent();
}

private void StartGame_Load(object sender, EventArgs e)
{
    //Loads the ball on the screen at bottom of the window
    bBA1 = this.ClientSize.Width / 5; //The x axis the ball is loaded at
    bBA2 = this.ClientSize.Height - 10; //The y axis the ball is …
Run Code Online (Sandbox Code Playgroud)

c# arrays

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

标签 统计

arrays ×1

c# ×1