-1

I have a pictureBox that I want to specify by combining two other strings. Lets say the pictureBox was called Tile20 what would I do? How do I make this work?:

if("Tile" + "20".Tag == "Hello")
{
     rest of the code...
}
jonathanh8686
  • 78
  • 1
  • 6
  • No, you need to access the object of `PictureBox` class to do this. Check this for more details: http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox(v=vs.110).aspx – shree.pat18 Aug 12 '14 at 06:27

1 Answers1

1

Try it like this:

PictureBox pictureBox = (PictureBox)this.Controls.Find(string.Concat("Tile","20")).FirstOrDefault();

if (pictureBox != null)
{
   if (pictureBox.Tag == "Hello")
   {
     rest of the code...
   }
}
nsgocev
  • 4,390
  • 28
  • 37