❔ Is there any way I can populate arrays with user input?
For example I want a user to fill up an array named randomNumbers with well, random numbers, can I do that? and if so, how?
11 Replies
1. Create an array
2. Loop over the array
3. For each index of the array, set the value at the index to a random number
You'll need to know a couple things for this, mainly how to create arrays, how to loop over them using a
for
loop, and how generate random numbers using the Random
class.Sounds like they want the random numbers to come from the user
I know how to use randoms and stuff but I want the numbers to come from the user
Do you know how to read user input?
Like a ReadLine thing but it populates an array instead of a variable
yep
Do you know how to turn a string into an int?
Convert.toInt32/64
I believe
int.Parse
is better, but yes
So you need to create the array, loop over it, and set each element to a number inputted by the useraa
I see thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.