交换代码C# [英] swap code c#

查看:76
本文介绍了交换代码C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何在包含图像的2个按钮之间进行交换
p.s.我做了2阵列2D记忆游戏"
我放入了包含不同图片的24个按钮,并在其上方放置了另外24个包含问号图片"的按钮.

System.Windows.Forms.Button [,] m =新
System.Windows.Forms.Button [4,6];
m [0,0] = b1;
m [0,1] = b2;
m [0,2] = b3;
m [0,3] = b4;
m [0,4] = b5;
m [0,5] = b6;
m [1,0] = b7;
m [1,1] = b8;
m [1,2] = b9;
m [1,3] = b9;
m [1,4] = b11;
m [1,5] = b12;
m [2,0] = b13;
m [2,1] = b14;
m [2,2] = b15;
m [2,3] = b16;
m [2,4] = b17;
m [2,5] = b18;
m [3,0] = b19;
m [3,1] = b20;
m [3,2] = b21;
m [3,3] = b22;
m [3,4] = b23;
m [3,5] = b24;

上方的按钮"

System.Windows.Forms.Button [,] n =新
System.Windows.Forms.Button [4,6];
n [0,0] = bt1;
n [0,1] = bt2;
n [0,2] = bt3;
n [0,3] = bt4;
n [0,4] = bt5;
n [0,5] = bt6;
n [1,0] = bt7;
n [1,1] = bt8;
n [1,2] = bt9;
n [1,3] = bt9;
n [1,4] = bt11;
n [1,5] = bt12;
n [2,0] = bt13;
n [2,1] = bt14;
n [2,2] = bt15;
n [2,3] = bt16;
n [2,4] = bt17;
n [2,5] = bt18;
n [3,0] = bt19;
n [3,1] = bt20;
n [3,2] = bt21;
n [3,3] = bt22;
n [3,4] = bt23;
n [3,5] = bt24;

how can i make swap between 2 buttons that contain images
p.s. i made 2 array 2D "memory game"
i put 24 buttons that contain different pictures and above them another 24 buttons that contain "Question mark picture"

System.Windows.Forms.Button[,] m = new
System.Windows.Forms.Button[4, 6];
m[0, 0] = b1;
m[0, 1] = b2;
m[0, 2] = b3;
m[0, 3] = b4;
m[0, 4] = b5;
m[0, 5] = b6;
m[1, 0] = b7;
m[1, 1] = b8;
m[1, 2] = b9;
m[1, 3] = b9;
m[1, 4] = b11;
m[1, 5] = b12;
m[2, 0] = b13;
m[2, 1] = b14;
m[2, 2] = b15;
m[2, 3] = b16;
m[2, 4] = b17;
m[2, 5] = b18;
m[3, 0] = b19;
m[3, 1] = b20;
m[3, 2] = b21;
m[3, 3] = b22;
m[3, 4] = b23;
m[3, 5] = b24;

"buttons that above"

System.Windows.Forms.Button[,] n = new
System.Windows.Forms.Button[4, 6];
n[0, 0] = bt1;
n[0, 1] = bt2;
n[0, 2] = bt3;
n[0, 3] = bt4;
n[0, 4] = bt5;
n[0, 5] = bt6;
n[1, 0] = bt7;
n[1, 1] = bt8;
n[1, 2] = bt9;
n[1, 3] = bt9;
n[1, 4] = bt11;
n[1, 5] = bt12;
n[2, 0] = bt13;
n[2, 1] = bt14;
n[2, 2] = bt15;
n[2, 3] = bt16;
n[2, 4] = bt17;
n[2, 5] = bt18;
n[3, 0] = bt19;
n[3, 1] = bt20;
n[3, 2] = bt21;
n[3, 3] = bt22;
n[3, 4] = bt23;
n[3, 5] = bt24;

推荐答案

通常来说,交换函数需要一个临时变量,例如
Generally speaking, a swap function needs a temporary variable, for instance
void swap(ref Button b1, ref Button b2)
{
  Button tmp = b1;
  b1 = b2;
  b2 = tmp; 
}



但是,我怀疑以上不是您想要的...:rolleyes:


[添加]
Univoter先生,您不喜欢交换功能吗?
顺便说一句:11111111111111111111111新年快乐!
[/添加]



However, I suspect the above is not what you intended... :rolleyes:


[added]
Hi, Mr. Univoter, don''t you like swap functions?
BTW: Happy new 11111111111111111111111 year!
[/added]


交换图像,而不是按钮.
Swap the images, not the buttons.


我如何进行图像交换? ?
how can i make image swap ???????????


这篇关于交换代码C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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