SHARE
TWEET

Random image generator

Darnock Jan 6th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public partial class Form1 : Form
  2.     {
  3.         public void ImageGenerator()
  4.         {
  5.  
  6.             string[] flagImageSources = new string[196];
  7.  
  8.             StreamReader flagImageSourceReader = File.OpenText("flagImageSourceFile.csv");
  9.  
  10.             for (int i = 0; i < flagImageSources.Length; i++)
  11.             {
  12.                 string s = flagImageSourceReader.ReadLine();
  13.                 flagImageSources[i] = s;
  14.             }
  15.  
  16.             Random numberGenerator = new Random();
  17.             int imageNumber = numberGenerator.Next(0, 196);
  18.  
  19.             string flagImageSrc = flagImageSources[imageNumber];
  20.  
  21.             flagPictureBox.ImageLocation = @flagImageSrc;
  22.         }
  23.  
  24.         public Form1()
  25.         {
  26.             InitializeComponent();
  27.  
  28.             ImageGenerator();
  29.         }
  30.  
  31.         private void submitBtn_Click(object sender, EventArgs e)
  32.         {
  33.             ImageGenerator();
  34.         }
  35.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top