比较两个对象 [英] comparing two objects
本文介绍了比较两个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我在条件比较中比较两个对象,但显示出一些错误,这是我的代码在这里
hi all i am comparing two objects in if condtion, but its showing some error this is my code here
Dim red As Object = Global.Frogy_Main_Screen.My.Resources.Resources.red_chair
Dim clkchr As Object = cb.BackgroundImage
If clkchr = red Then
MsgBox("Somehting")
End If
这里cb是我的按钮控件
我正面临这种错误.错误是
未为类型位图"和类型位图"定义运算符="="."
我应如何解决此错误.
here cb is my button control
i am facing this kind of error. the error is
"Operator ''='' is not defined for type ''Bitmap'' and type ''Bitmap''."
how shall i fix this error.
推荐答案
您可以使用Object.Equals()
http://msdn.microsoft.com/en-us/library/system.object. equals.aspx [^ ]
或者,您也可以自己实施(如果需要):
http://msdn.microsoft.com/en-us/library/ms173147.aspx [ ^ ]
祝你好运!
You can use Object.Equals()
http://msdn.microsoft.com/en-us/library/system.object.equals.aspx[^]
Or you could implement it yourself (if needed):
http://msdn.microsoft.com/en-us/library/ms173147.aspx[^]
Good luck!
if clkchr.Equals(red) then
...
end if
编辑==========
糟糕,戴夫(Dave)到达了第一. :)
EDIT ==========
Oops, Dave got there 1st. :)
这篇关于比较两个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文