Answer to Question #10415 in C# for csharp

Question #10415
how to make random images in c sharp?
1
Expert's answer
2012-06-05T11:07:00-0400
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RandomImage
{
public partial class Form1 : Form
{
private List<Image> listofImage = new List<Image>();
private Random randomnumber = new Random();
public Form1()
{

InitializeComponent();
for (int i = 1; i <= 8; i++)//8 images add to list listofImage
{
Image im = Image.FromFile(i.ToString() + ".jpg");
listofImage.Add(im);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
this.BackgroundImage = listofImage[randomnumber.Next(1, 8)];//Select random number from
List
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
07.06.12, 14:41

You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!

george
05.06.12, 19:51

thank you it was harder than i thought

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS