I'm trying to do a value assignment on a certain index of a String, however, I get the following error that I do not understand the reason:
System.ArgumentOutOfRangeException: 'The index was out of range. It should be non-negative and smaller than the size of the collection. * '
string tela;
int counter = 0;
StringBuilder telaBuilder = new StringBuilder();
private void btnSendWord_Click(object sender, EventArgs e)
{
char letra = Convert.ToChar(txtGetWord.Text);
Boolean codigoVerificador;
codigoVerificador = verificador.VerificaLetra(comboPalavra[0],letra);
if (codigoVerificador == true)
{
foreach(char c in comboPalavra[0].ToCharArray())
{
counter = counter + 1;
if(c == letra)
{
telaBuilder[counter] = Convert.ToChar( letra);
tela = telaBuilder.ToString();
}
}
}
}