This might be a little "smelly" but it's better than try to modify the array when you are in an iteration.
The idea is this: save all the indexes where the word appears, and then erase those words. This is not the best solution, but it can help you with your problem. I highly recommends you to read about "Lists" because there are great on C# and it's easier use them than use arrays
K="{"book","car"};
//Never use a number, try to use the .length propertie
List<int> indexes=new List<int>();//using lists is easier than arrays
enter code here
for (i = 0; i < K.length; i++)
{
if (keywords.Contains(K[i]))
{
//You save the index where the word is
indexes.add(i);
}
}
//Here you take those indexes and create a new Array
int[] theNewArray=new int[K.length-indexes.Count];
int positionInTheNewArray=0;
for (i = 0; i < K.length; i++)
{
if(!indexes.Contains(i))
{ theNewArray[positionInTheNewArray]=K[i];
positionInTheNewArray++;
}
}
}
That fits if your array allows duplicated words and also if duplicated words are not allowed.