1

I have two Resouces: 1.jpg, 2.jpg. I'm getting access to them like:

pictureBox1.Image = Properties.Resources.Computer1;
pictureBox1.Image = Properties.Resources.Computer2;

But what if I want to access it by index like:

pictureBox1.Image = Properties.Resources.Computer[0];

How can I do it?

Dima
  • 3,363
  • 9
  • 31
  • 69

1 Answers1

4

You've already made image name by using index. So, you can access those files, like below,

for(int i = 0; i < 2; i++) 
{

  pictureBox1.Image = (Image)Properties.Resources.ResourceManager.GetObject("Computer" + i);

}

And, I'd like to recommend to read below articles.

Load image from resources

C# Resource Array

Community
  • 1
  • 1
hyun
  • 2,097
  • 2
  • 17
  • 20