this is my array,

public String[] Swears = new string[22] {"bad words"}

there are 22 swear words included in this, not gonna put them here. this works perfectly but doesnt seem to work in the forloop

this is the text box that the user inputs their name into, and it includes a remove statement that doesnt seem to work. when this code runs, it can only remove the first 4 swears, but the swears after that cause an error

public void player1Name_TextChanged(object sender, EventArgs e)
    {
        for(int i =0; i<22; i++)
        {
           
            if (player1Name.Text == Swears[i])
            {
                int o = player1Name.Text.Length;
                player1Name.Text = (Swears[i].Remove(4));
                MessageBox.Show("please enter a valid Name");
            }
        }
       
    }
0

There are 0 best solutions below