Drawing of predefined values

Asked

Viewed 345 times

0

I have two Textbox (txtUM, txtDois), and would like to draw some pre-programmed date/string (Between dates: 07:55, 07:56, 07:57, 07:58, 07:59, 08:00, 08:01, 08:02, 08:03, 08:04, 08:05 ).

The number that was drawn would put in the textbox (txtUM), and after another draw another value on (txtDois). It would be something like the Random, but in that case I already have the values that should be drawn.

1 answer

2


place dates within an array and draw an integer to match the index of the array.

string[] datas = new string[] { "data 1", "data 2", "data n" };
Random r = new Random();

txtUM.Text = datas[r.Next(datas.Length)];
txtDOIS.Text = datas[r.Next(datas.Length)];
  • 1

    Note that with this answer it is possible to select the same value twice.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.