我在做一个翻翻看(记忆记牌的那种)的游戏,比如放了8个picturebox,当我第一次点击picturebox3,它显示了一张图片,然后我点击picturebox2,此时我要做的就是让picturebox2的图片跟之前点击过的那个picturebox进行比较对吧,那么我在picturebox2中的比较的那段代码怎么写呢?总不能直接写类似于:if(picturebox2.image==picturebox3.image)吧。因为点击picturebox3的是用户,并不是程序员啊!请大家仔细理解理解,我只能这样描述了。帮忙呀。
private void pictureBox_Click(object sender, EventArgs e)
{
if (sender != lastclick && lastclick != null)
{
if (lastclick.Image == (sender as PictureBox).Image)
{
MessageBox.Show("相同");
}
else
MessageBox.Show("不相同");
}
lastclick = sender as PictureBox;
}