❔ Array mess
I basically want this to return all of the numbers input into the array, sorted into smallest to largest
13 Replies
However it returns this
int count = 0;
ArrayList raffleList = new ArrayList();
int[] raffleNumber = new int[5];
foreach (int number in raffleNumber)
{
Console.WriteLine("Please write a number from 1-60 that you would like to choose.");
raffleNumber[count] = Convert.ToInt32(Console.ReadLine());
}
raffleList.Add(raffleNumber);
Array.Sort(raffleNumber);
Console.WriteLine(raffleNumber);
Console.ReadLine();
Help would be appreciated
You can't just pass an array to console writeline
Use
string.Join
to turn it into a string
Also, use a for loop, not a foreachAnd god do not use
ArrayList
Maybe something like this?
Its part of my course as like practice so i need to use it somewhere, but if it cant be used here then thats okay
If it's part of your ancient course then sure it's fine, but you should never ever use it in any other circumstances.
Yeah its an Alevel course soooo i need to at least learn how it works, but from ur ominous message i get that i shouldnt use it 😭
Its a 20 year old class with literally not a single usecase left
It still exists only for backward compatibility, and should never be used
Yeah sorry I should like actually explain it.
ArrayList
was added all the way back in C# 1, back when the language didn't have this nifty thing called generics, but then in C# 2 generics were added along with the List<T>
class, which is better in literally every single way. So tl;dr: ArrayList
is really old and has no purpose for existing.
sniped again Your text better thou
You know I ❤️ you right?
Okay i think i might just ignore it then
Makes my life easier
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.