-
February 13th, 2013, 12:41 PM
#1
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:
int[] array;
array = new int [3];
array[0] = 1;
array[1] = 7;
array[2] = 9;
Random random = new Random();
int number = random.Next(array.Length);
System.Console.WriteLine(array[number]);
Console.ReadKey();
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|