سؤال

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?

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top