Index was outside the bounds of the array with randomization function

34 Views Asked by At

So I've tried to create a randomization function for a game to randomly generate characters from an array and add the result into another however it hasn't really worked and keeps throwing an "Index was outside the bounds of the array" error and I'm not too sure why. :( I've looked online and haven't really found any solutions that worked.

I've tried changing the dice to start at zero or one as well as changing the maximum number accordingly, I've also changed the character array from dynamic to fixed and nothing I've done has helped as its still the same line with the same error

Screenshot of code throwing the error

the array was declared as (couldn't fit it in a screenshot)

string[] player1_characters = new string[13] { "Xingqiu", "Razor", "Bennett", "Aether", "Kaeya", "amber", "fischl", "noelle", "Lisa", "Xinyan", "Ningguang", "chongyun", "barbara" };

The other array is declared as:

 string[] player1_output = new string[] { };

I'm pretty new to c# and don't know what's going on with it XD any help would be amazing ^^

0

There are 0 best solutions below