This is my code. I know the error is common but I still can't seem to figure out why this error appears. I am trying to remove the vowels from the words in the Instruments Array. I made an If-statement to make sure the error is not caused by Instrument[a]being null.
string[] Instruments = new String[7];
Instruments[0] = "hej";
Instruments[1] = "cello";
Instruments[2] = "guitar";
Instruments[3] = "violin";
Instruments[4] = "double bass";
Instruments[5] = "drums";
string[] Vowels = new String[9];
Vowels[0] = "e";
Vowels[1] = "y";
Vowels[2] = "u";
Vowels[3] = "i";
Vowels[4] = "o";
Vowels[5] = "å";
Vowels[6] = "a";
Vowels[7] = "æ";
Vowels[8] = "ø";
string message = "start: ";
for (int a = 0; a < Instruments.Length; a++)
{
string InstrumentCurrent = Instruments[a];
Console.WriteLine(Instruments[a]);
for (int i = 0; i < Vowels.Length; i++)
{
if (InstrumentCurrent != null);
{
//InstrurmentCurrent = InstrumentCurrent += ""; (If I uncomment this, the code works fine)
InstrumentCurrent = InstrumentCurrent.Replace(Vowels[i], "");
}
}
message += InstrumentCurrent;
message += ", ";
}
MessageBox.Show(message);