문제

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