Can we assign a List(Array) as key to a dictionary?

Is it necessary that a dictionary’s key should be a string or int or other data type. Can it hold a List (or Array) as a key.

technically it is possible:


But it is recommended to cross check why a List / array is needed for a key. Can you tell more about this motivation? thanks

Keep this in mind:

both arrays are individual objects, used for the key uniqness check, but have same content.

1 Like


@ppr is right, we could create a variable.
please look at my screenshot as well.

1 Like

there is a formula:

total = base + a - d

the base is dependent on three things : x, y,z. Refer below table

x y z base
2000 25 1 2334
3000 35 2 3442
4000 45 3 4503

and similarly the values of ‘a’ and ‘d’ depend on other variables. There are many possibilities of diff x, y, z resulting different base. There is an excel sheet for all possibilites. I am thinking of assigning the array of {x, y, z} as key and base as value.
so that it can directly be put in the formula above. Similarly it can be done for ‘a’ and ‘d’. Otherwise I have to use nested for loops and nested if-else. Any other approach will be appreciated.


check updated post as it has also the risk of fail.
Maybe you concat xyz on string base 2000_25_1 and use the concated string as key

The values will be very different. So it won’t fail.


Another solution: Using Tuple as key , as the following, FYI.

Main.xaml (8.0 KB)



please check the contains key:
it is false because the array is another object identity

{1,2} first key
{1,2} second key
{1,2} key used for contains key check

it is always {1,2} but different objects, and therefore not intuitive usable as we do know e.g. from a string key

String concatenation would be better approach.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.