how do i run a random function from array?

nadavrock

New member
Joined
Jul 20, 2019
Messages
2
Programming Experience
Beginner
say i have an array of functions. how do i select one at random and run it?
 
You would use Random Class to select an index in array and invoke that delegate.
 
Doing something randomly pretty much ALWAYS involves using the Random class that JohnH suggests. It will generate a random number and then it's up to you to use that number is whatever way is appropriate for your specific case. If you need a random item from a list of any kind, using the random number as an index is the obvious choice and that's how it gets used most often, in my experience at least.
 
Back
Top Bottom