fairly new C# developer here. I'm trying attempting to develop a mad lib generator. I have a button button_1 labeled "verb" that is supposed to generate a random verb. The verb comes from a string array, which is a list of verbs. I have another button button_5 labeled "add new verb" that is supposed to add the verb in the corresponding text box to the verb array. The problem I'm having is that it is only generating the last verb that I entered when I click button_1 which is labeled "verb".
Here is what the code looks like:
namespace WindowsFormsApplication1
{
public class Arrays
{
public static string[] verbarray = new string[10];
}
}
public void button5_Click(object sender, EventArgs e)
{
for (int iverb = 0; iverb < Arrays.verbarray.Length; iverb++)
{
Arrays.verbarray[iverb] = Convert.ToString(this.txtaddverb.Text);
}
}
public void button1_Click(object sender, EventArgs e)
{
Random randomverb = new Random();
verb.Text = Arrays.verbarray[randomverb.Next(0, Arrays.verbarray.Length)];
}