mardi 20 janvier 2015

How to add random string array to string in C#?

I have a form that need to filter the user input game 1 to 4 games and then user need to enter animal number to the enabled fixed animal textbox.


again user also need to enter how many game on the textbox before the random button.


Total game (the random output) is 5 animal example: 23-22-12-34-40 after click the random button then it will fixed the first 3 animal number then random the rest 2 animal number and put next to the 3 fixed animal until game equal to the total game. Blank example:


enter image description here


The below image is the example input filter: enter image description here


Based on the example image the total game is 3 then I want the output random to display in the listbox as follow:



23-22-12-34-40


23-22-12-14-34


23-22-12-11-17



I tried to filter only one game but I still not luck:



TextBox[] GameTwoFixed = new TextBox[4] { txtFixedAnimalSales1, txtFixedAnimalSales2, txtFixedAnimalSales3, txtFixedAnimalSales4 };
string[] NumberPlay1 = new string[5];
string play = txtFixedTypeTwo.Text;
string Game = "";
string CountGame = txtCountGameTwo.Text;
if(play != "")
{
if (CountGame != "")
{
if (play == "1")
{
string GetRandom = RandomGenerator();
List<string> setGame = new List<string>();
do
{
if (!setGame.Contains(GetRandom))
{
setGame.Add(GetRandom);
}
}
while (setGame.Count == Convert.ToInt32(CountGame));
}
}
}


So is there anyway to handle this?


Thanks in advance





Aucun commentaire:

Enregistrer un commentaire