C
C#15mo ago
Forgatsu

❔ Why it wont let me type array ?

Cant figure it out why im getting this, anyone can explain?
No description
18 Replies
HtmlCompiler
HtmlCompiler15mo ago
did jump the code using set next statement? what does test contain there?
Forgatsu
ForgatsuOP15mo ago
shouldnt it contain strings typed out in it ?
TheRanger
TheRanger15mo ago
are u in release mode? the error is in test[3] = "Zolas"; line if ur in debug mode, that line should glow instead anyway the array can only contain 3 elements and u provided 4
HtmlCompiler
HtmlCompiler15mo ago
man i missed that, i suspected it tho
Forgatsu
ForgatsuOP15mo ago
oh i tought 3 means = 4, yk 0,1,2,3
TheRanger
TheRanger15mo ago
not when ur defining a size of the array
Forgatsu
ForgatsuOP15mo ago
it works now thanks. Been staring for good 10mins couldnt figure out error.
xLelik
xLelik15mo ago
you created an array with 3 elements, the element numbers start from 0, that is, [0], [1], [2]. You created a non-existent index
Forgatsu
ForgatsuOP15mo ago
Can i randomize array which is being typed? Like Console.WriteLine(test[Random index 1-3]); ?
Pobiega
Pobiega15mo ago
Yes.
Forgatsu
ForgatsuOP15mo ago
No description
Forgatsu
ForgatsuOP15mo ago
i tried this way but seems like im doing something not right xd
Pobiega
Pobiega15mo ago
Google how to get a random number Don't just guess
xLelik
xLelik15mo ago
here is the correct solution
No description
Forgatsu
ForgatsuOP15mo ago
i did like this
No description
Forgatsu
ForgatsuOP15mo ago
still not sure what next means but il learn it in future.
Pobiega
Pobiega15mo ago
Next is how you generate a number. It's a method on the class Random
Accord
Accord15mo ago
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.

Did you find this page helpful?