New and noob programmer here.
Im trying to run this code and it compiles, but everytime I try to run it, I get this error.
Any Idea what might cause it and how to fix it?
public partial class Form2 : Form
{
//Atributos (Se crea el array para los nombres)
string[] listaJugadores = new string[5];
Label[] listaLabels = new Label[5];
public int contador = 0;
public Form2()
{
InitializeComponent();
}
//Se activa el boton para mostrar los nombres registrados
private void button1_Click(object sender, EventArgs e)
{
//Esto hara que se agureguen los nombres a la lista de jugadores
listaJugadores[contador] = txtNombres.Text;
listaLabels[contador].Text = txtNombres.Text;
contador++;
Random rnd = new Random();
int value = rnd.Next(0, 10);
textBox1.Text = value.ToString();
}
}