vendredi 2 février 2018

How to randomize elements in an array C# [duplicate]

This question already has an answer here:

I have an array of prices all with a value of zero currently:

int[] prices = { 0, 0, 0, 0, 0, 0 };

I have been searching for a way to randomize each element of the array after a user clicks a button so that after each click element 0 becomes randomized to a unique value as will elements 2, 3 so on and so fourth, however, I can only figure out how to shuffle the array.

I'm very new to c# and the only way I can figure out how to do this is to create individual INT variables and randomize each value separately but this would make my code messy i think.

Is this possible?

Thanks,




Aucun commentaire:

Enregistrer un commentaire