无法在"If"语句中使用=运算符

sub*_*nki 1 vb.net

为什么我不能在这里使用=运算符.无论如何要解决这个问题?

 If PictureBox1.Image = My.Resources.pic001 Then
       x = 1
    Else
       x = 0
    End If
Run Code Online (Sandbox Code Playgroud)

错误消息是:

没有为类型'System.Drawing.Image'和'System.Drawing.Bitmap'定义Operator'='

Dan*_*ger 5

假设PictureBox1.Image引用与My.Resources.pic001相同的Image对象,那么您可以使用:

If Object.ReferenceEquals(PictureBox1.Image, My.Resources.pic001) Then
Run Code Online (Sandbox Code Playgroud)