how to make random images in c sharp?
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!
Learn more about our help with Assignments:
C#