0

How I can delete a numbers from Array “a” that contained in Array “b”?

int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int[] b = {3, 9};
1
  • you can see something similar here link Commented Jul 30, 2016 at 21:25

2 Answers 2

5

You cannot delete items from an array. What you can do is create another array that contains the items from a except the items in b and assign it to variable a like this:

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

Comments

0

You can copy b into a list, and then delete elements from it.

List<int> bList = new List<int>();
bList.AddRange(b);
foreach (int check in a)
{
    if (bList.Contains(check))
    {
        bList.Remove(check);
    }
}
b = bList.ToArray();

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.