I have a small program to roll two dices. So the user should enter a number to be the frequency number of the dice to be rolled when user click start, the program will show two different column with each fill with random number based on frequency which user inputted.
The program looks like this:
After the random number showed up. The program will sum the random numbers (i filled the random numbers inside an array for each dices), I'm confuse, how can I sum two array from different method?
This is my code so far:
private void button1_Click(object sender, EventArgs e)
{
firstDice();
secondDice();
}
Random vran = new Random();
void firstDice()
{
string temp = null;
int x = Convert.ToInt32(textBox1.Text);
int[] arr = new int[x];
for (int i = 0;i<x;i++)
{
int a = vran.Next(1, 6);
arr[i] = a;
temp += a + " ";
textBox2.Text = temp;
}
}
void secondDice()
{
string temp = null;
int x = Convert.ToInt32(textBox1.Text);
int[] arr = new int[x];
for (int i = 0; i < x; i++)
{
int a = vran.Next(1, 6);
arr[i] = a;
temp += a + " ";
textBox3.Text = temp;
}
}
Notes: the array will sum for each value (i.e array[0] + array[0].. and so on).

button1_Clickcould then sum the arrays they return.int[] secondDice() { /* ...stuff...*/ return arr; }