First off, i’d like to say that my programming knowledge is very basic and got a learn as you go style. So please bear with me if i sound stupid.
So i have a multi dimensional string array, a part of which is:
X Y
4,1 Adelaide
4,2 Interlagos
4,3 Sakhir
4,4 Hungaroring
4,5 Estoril
4,6 Barcelona
4,7 Silverstone
4,8 Mugello
4,9 Hockenheim
4,10 Monte Carlo
In the above table, X and Y are the 2 dimensions of the array.
Now i have another string array with elements from X dimension of the above array in unsorted fashion. For example,
4,6
5,15
3,7
10,12
etc…
Now what i want to do is write a code which looks into array #2 and assigns a corresponding element from dimension Y of the array #1.
For example, when the code encounters 4,6 in array #2, i want the code to assign the corresponding value which is Barcelona.
Just the basic snippet or algorithm is what i’m looking for. I’ll do the rest myself.
Thanks in advance!
Sounds like table 1 should really be a
Dictionary<string, string>, mapping “4,6” to “Barcelona”. Then you can just do:Note that this will throw an exception if any of the keys isn’t mapped – if that’s not what you want, please clarify the requirements.
It’s not clear how you’re getting this data, or whether your “multi-dimensional string array” is a
string[,]or astring[][]. If you have to receive it as a string array, give us more details and we can explain how to convert that into the dictionary.