I'm still new in c#. The code been working for months without error until recently. It is constantly throw out the error: Unhandled Exception System.IndexOutofRangeException: Index was outside the bounds of the array.
I'm not sure where the error happening in the code.
private Random rnd = new Random();
string[] slots = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13" };
private int slot1, slot2, slot3 = 0;
if (message.Equals("!game"))
{
if (user == luckychance)
{
slot1 = 0;
slot2 = 0;
slot3 = rnd.Next(0, 6);
luckychance = "";
}
else
{
slot1 = rnd.Next(0, 14);
slot2 = rnd.Next(0, 14);
slot3 = rnd.Next(0, 14);
}
if (slot1 == slot2 && slot1 == slot3)
{
sendMessage(slots[slot1] + " | " + slots[slot2] + " | " + slots[slot3] + " win", 2);
}
else
{
sendMessage(slots[slot1] + " | " + slots[slot2] + " | " + slots[slot3] + " lost", 2);
}
}
rnd.Nextcall (hint if it isn't), read the documentation carefully.