小编Ник*_*ров的帖子

如何检查图像对象是否与资源中的对象相同?

因此,我正在尝试创建一个简单的程序,只需在单击时更改图片框中的图片即可.我目前只使用两张图片,所以我的图片框点击事件功能的代码如下所示:

private void pictureBox1_Click(object sender, EventArgs e)
    {
       if (pictureBox1.Image == Labirint.Properties.Resources.first)
            pictureBox1.Image = Labirint.Properties.Resources.reitmi;
       else if (pictureBox1.Image == Labirint.Properties.Resources.reitmi)
            pictureBox1.Image = Labirint.Properties.Resources.first;
    }
Run Code Online (Sandbox Code Playgroud)

由于某种原因if语句不起作用,图片不会改变.我该怎么办?


注:原代码包含与第二个bug if第一的毁灭效果,如果条件与修复所建议的工作Cyral的答案,但增加else并没有解决这个问题-通过代码步进else仍然显示没有匹配的任何图像.

if (pictureBox1.Image == Labirint.Properties.Resources.first)
    pictureBox1.Image = Labirint.Properties.Resources.reitmi;
if (pictureBox1.Image == Labirint.Properties.Resources.reitmi) // was missing else
    pictureBox1.Image = Labirint.Properties.Resources.first; 
Run Code Online (Sandbox Code Playgroud)

c# embedded-resource

4
推荐指数
2
解决办法
3471
查看次数

使用按插入方式排序的参数创建哈希映射

我想更改 std::map (它是哈希函数),以便在迭代时以插入的方式返回对。我尝试过使用无序地图,但没有成功。所以我想我必须创建一个哈希函数,该函数每次都会递增并返回更大的值。我怎样才能做到这一点?我不使用大数据,所以性能不是问题。

c++ hash-function hashmap

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

标签 统计

c# ×1

c++ ×1

embedded-resource ×1

hash-function ×1

hashmap ×1