Reputation: 3
I have 3 Image controls that are named: slot1, slot2 and slot3. If I want to check that slot1, slot2 and slot3 have the same image source, I do this:
if (slot1.Source == slot2.Source && slot2.Source == slot3.Source && slot3.Source == slot1.Source)
{
MessageBox.Show("sss");
}
But it doesn't show me the message box. I tried different methods but they didn't show the message box too. What did I do wrong?
Upvotes: 0
Views: 731
Reputation: 169270
I put
Console.WriteLine(slot1.Source)
and same for all slots and it showed"pack://application:,,,/Anime Clicker;component/Images/heroFaceImages/GohanFace.png"
3 times
Compare the string representations then:
if (slot1.Source != null && slot2.Source != null && slot3.Source != null
&& slot1.Source.ToString() == slot2.Source.ToString()
&& slot2.Source.ToString() == slot3.Source.ToString())
{
MessageBox.Show("sss");
}
Upvotes: 1