C# 我的代码赢了';t在if参数例如if中使用picturebox资源(pb3.Image==Whack_A_Mole.Properties.resources.hjä;rta)

C# 我的代码赢了';t在if参数例如if中使用picturebox资源(pb3.Image==Whack_A_Mole.Properties.resources.hjä;rta),c#,if-statement,picturebox,C#,If Statement,Picturebox,当我尝试使用picturebox资源映像作为我的if和else if代码的激活时,我的代码跳过了我的if参数 我的代码: public void liven() { if(pb3.Image==Whack_A_Mole.Properties.resources.picture) { 丽芙--; pb3.Image=Whack_A_Mole.Properties.Resources.other_picture; pb3.Refresh(); } } 在程序开始时将资源图像存储在数组或列表中-MyA

当我尝试使用picturebox资源映像作为我的
if
else if
代码的激活时,我的代码跳过了我的
if
参数

我的代码:

public void liven()
{
if(pb3.Image==Whack_A_Mole.Properties.resources.picture)
{
丽芙--;
pb3.Image=Whack_A_Mole.Properties.Resources.other_picture;
pb3.Refresh();
}
}

在程序开始时将资源图像存储在数组或列表中-
MyApp.Properties.Resources.picture
是一个工厂而不是集合,因此每次都会创建一个新的唯一对象。它永远不会与其他图像相等。存储在一个集合中,确保只有一个集合,这样它将匹配并且您的应用程序不会泄漏。谢谢您的帮助:D