February 13th, 2013, 12:41 PM
C# How can i randomly assign numbers to an array?
Hello! I am new to c# so this may be a basic question, i am also new to this forum so hello all!
I am in progress of planning a "deal or no deal" game with c#.
I currently have this code:
array = new int ;
array = 1;
array = 7;
array = 9;
Random random = new Random();
int number = random.Next(array.Length);
This just randomly prints out a value 1, 7 or 9 if the array value is 0, 1 will always be printed out to the screen.
I want it so when the game starts up the numbers would be randomly assigned so when the game starts up one game the 0 value in the array could be 1 7 or 9.
Obviously with deal or no deal there will be 20+ value boxes there for i would need to randomly assign 20+ assigned numbers to random boxs
Sorry if i havent been clear, if you need clarification please leave a comment
Tags for this Thread
Click Here to Expand Forum to Full Width