Accessing Dictionary via Dictionary key

Alright! I have a quick question that I didn’t find any answer onto. I created a variable that is named mapping wich is a Dictionary<Dictionary<int,int>,int>. I did that because there is a mapping ( grid ) system on the x and z axis of the ground and I want to link the Dictionary<int,int> ( a square in the grid with a x and a z ) to an object’s ID wich would be on this spot. The problem is that whenever I affect a Dictionary in the mapping system, it says that it just can’t be accessed. I’m starting to think that I can’t use Dictionaries as keys. Any help?

Using a Dictionary as a key for another dictionary is… completely nonsensical. I can’t think of a scenario where that would ever make sense. (Maybe if you were coding an inspector interface and wanted to store the folded/unfolded state of many Dictionaries…)

I think you may be misunderstanding what a Dictionary is. You seem to be using the inner one like it’s a Vector2 for ints - you’re storing coordinates there for a grid system, right?

You can use pretty much any representation of a grid cell as your key - Vector2, a custom Vector2-like class that has ints, a string composed of the two coordinates - but not a Dictionary.

1 Like

Thanks a lot, I don’t know why I didn’t think of this. I don’t even have to test it to know you’re right!