What’s the best data structure for a 2D array of size unknown x 2. Which means one dimension is dynamic (list of grocery items) and the other is fixed (price and quantity).
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.
Personally, I would use a
List<T>, with T being a custom class.This would be something like:
Then just do:
This gives you the flexibility to have your price and quanities, for any number of items. It’s easy to add to this as needed, and make it as long as you want.