I need a C# collection from which I can as quickly as possible pick out a random element, but also add new elements to. It is for a scrabble bag of letter blocks. Which one should I use?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Anything implementing
IList(or, more probablyIList<T>) as these can be referenced by index. Its very easy to pick a random number in the range0 < n < list.Count-1and get that item from the list.eg/