C#如何对棋盘的数字进行排序 [英] C# how to sort chess board's numbers

查看:115
本文介绍了C#如何对棋盘的数字进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要像这样排序棋盘的数字。

8

7

6

5

4

3

2

1



但在我的情况下,它的排序方式是这样的。

1

2

3

4

5

6

7

8

我的错误是什么?



我尝试过:



I need to sort chess board's numbers like this`
8
7
6
5
4
3
2
1

but in my case it sorted like this`
1
2
3
4
5
6
7
8
what's my mistake?

What I have tried:

for (int i = 8; i > 0; i--)
            {
                Label lab = new Label();
                lab.Text = i.ToString();
                lab.Font = new Font("Tahoma", 18);
                lab.Location = new Point(0, 50 * i);
                lab.Width = 50;
                lab.Height = 26;
                this.Controls.Add(lab);
            }

推荐答案

替换

Replace
引用:

lab.Location = new Point(0,50 * i);

lab.Location = new Point(0, 50 * i);

使用

With

lab.Location = new Point(0, 50 * (9-i));


这篇关于C#如何对棋盘的数字进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆