Best way to go about a programming task


Well-known member
Sep 7, 2020
Programming Experience
Hi Guy's,
I am not sure if I am heading in the right direction with a task I have to complete and I have no one at work to ask.
The task involves opening an excel spread sheet grabbing two columns of data, three if possible.
Then retrieving the data to use like a look up. What is the best way to do this.
Two / three dimensional arrays, dictionary?

If I use the code below. How do I get the second element based on the value of the first element.
Where first element value = three, give me associated second element value (four)


string[,] array2Db = new string[3, 2] { { "one", "two" }, { "three", "four" },
                                        { "five", "six" } };

            MessageBox.Show(array2Db[0, 0]);
            MessageBox.Show(array2Db[0, 1]);
            MessageBox.Show(array2Db[1, 0]);
            MessageBox.Show(array2Db[1, 1]);
            MessageBox.Show(array2Db[2, 0]);
            MessageBox.Show(array2Db[2, 1]);
Last edited:


Staff member
Apr 6, 2019
Chesapeake, VA
Programming Experience
Dictionary<TKey, TValue> is the most appropriate data structure for that kind of operation in general. If you are a hard core computer scientist, then the rule of thumb is an array is good enough if you have less than 100 keys, and they are stored in sorted order in the array. Personally, stick with the dictionary unless your performance profiling shows that it is the dictionary lookup that is slowing you down. The dictionary best conveys the intent of the code to other experienced programmers. A good programmer should strive to communicate with future readers of the code as their first goal, and only incidentally have working code that a computer can execute.
Top Bottom