Why is this dictionnary.containkey not returning true ???

Ok, Tried to get this thing working for a few hour now and it just wont. I got a “Tile” gameobject that the player can place, when the player place the tile, it check in a dictionary that use the tile position as the key and the tile script as the value to see if there is a tile at that position and if there are adjacent tiles. Some tiles have special function if something is “under” them, no mater if they are rotated , so I use this to find if a tile is present in the dictionary under it :

Vector3 downPos = transform.TransformPoint(Vector3.down);
//is a tile under this one
bool downTile= false;

if (tileDict.ContainsKey(downPos))
            {
                downTile = true;
            }
}

but even if the key exist, tileDict.ContainsKey(downPos) always return false !

but if i try this :

 foreach (Vector3 tilePos in tileDict.Keys)
      {
            if (tilePos == downPos)
                  {
                         downTile = true;
                  }
  }

it find the key and set the variable to true ! why can’t containkey find it ?

Will be answering my own question in case someone else find this and got the same problem, I found out after some research that sometime, dont know why, the hashcode is different for the same vector 3 value. So when I have a value of lets say, vector3(0.0,1.0,0.0) as a key and I try to find if it exist in my dictionary using a vector3 variable with the exact same value, sometime the hashcode of those 2 vector3 is not the same (it appear to be somewhat random as sometime it work, other time not).

My game use only vector3 in increment of 1 and I always round the value to int before assigning them as key as a sanity check, so its not a flot error (or at least should not be).

To solve the probleme, I wrote a simple IEqualityComparer class and used that as the comparator for my dictionnary. In my class I always round the value to int before cheking them, so now when I try dictionary.containkey it always work. I guess I could also have created a suctom vector3 class that take int instead of float but in my case its not needed and probably would be overkill.