I have the following array:
private int[,] testSamples = new testSamples[101,101];
It’s supposed to represent a roster, with column 0 to 100 and row 0 to 100. In this rosters, various chemical liquids are dropped. The person I’m doing this for wants to work in such a way that he can take care of the container with the most liquid in it first.
So, I need to get the data out and printed in this manner:
testSamples[35,40] = 12
testSamples[11,12] = 11
testSamples[92,14] = 10
testSamples[18,3] = 10
testSamples[1,61] = 7
...
For instance.
I’ve been cracking my head over this for a few days, I’ve looked into some other questions here on StackoverFlow, but I can’t get any of them to work.
Is there a way to do this, or should I give up on arrays and go for another sort of container, like ArrayLists or List items?
Here’s a suggestion that I think ends up being quite similar to Richard’s, but without using LINQ.
Write a quick struct (something like this may even exist already) that includes three values: x, y, and value. Like this:
Then you can collapse your
int[,]array into any sortable one-dimensional collection ofSampleSlotobjects you like; I’d probably go with aList<SampleSlot>: