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.
Also:
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.
Thanks.
@kumar.varun2
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.
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.