0

I am creating a simple Bingo game.

I stored the different number in a String Array

    String[] number = new[] { "" };
    
    if (lblLetter.Text == "B")
    {
        //number = new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
    }
    if (lblLetter.Text == "I")
    {
        //number = new[] { "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" };
    }
    if (lblLetter.Text == "N")
    {
        //number = new[] { "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45" };
    }
    if (lblLetter.Text == "G")
    {
        //number = new[] { "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60" };
    }
    if (lblLetter.Text == "O")
    {
        number = new[] { "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75" };
    }

I used a List Array to store the numbers that was already selected on the bingo thus should be removed on the String Array

public List<string> exceptions = new List<string>();

Appending the label Value to it

exceptions.Add(lblNumber.Text);

Now I want to remove specific Items on String Array that is found on the exceptions List String

I'm confused on how to do this, Any help will be appreciated.

2
  • Please explain more in detail Commented Dec 6, 2022 at 8:23
  • The exceptions list string contains the numbers I want to remove on number list array Commented Dec 6, 2022 at 8:25

1 Answer 1

2

You can use Except.

number = number.Except(exceptions).ToArray();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.