I tried to write a shuffle string array algo but I get a null reference error.. I can't figure out why..
public static string[] arrRandomized;
public static string[] ShuffleWords(string[] Words)
{
Random generator = new Random();
for (int i=0;i < Words.Length; i++) {
int pos = generator.Next(Words.Length);
Console.WriteLine(Words[pos]); // I SEE RANDOM ITEM
Console.Read(); // NULL REFERENCE ERROR AFTER THIS
if (Words[pos] != null)
{
arrRandomized[i] = Words[pos];
//remove item at pos so I get no duplicates
Words[pos] = null;
}
}
I don't want to use ArrayList, i have my reasons but thats off topic I just want to know how come this isn't working :/ thanks