unity get from dictionary code example

Example 1: unity dictionary

//create dictionary "test", with key as float and value as GameObject
private Dictionary<float, GameObject> test = new Dictionary<float, GameObject>();

//add thing to dictionary
private void addToDictionary()
{
  //add key 10 and this gameObject
  test.Add(10, transform.gameObject);
}

private void printFromDictionary()
{
  //try to get value and save it as out GameObject result
  test.TryGetValue(10, out GameObject result);
  //then print that result
  print(result);
}

private void deleteFromDictionary()
{
  //remove key and gameObject 10 from our Dictionary
  test.Remove(10);
}

Example 2: unity dictionary get value

if (!haveMisionsAsigned && gameRecord.searchedArea == null)
        {
            for (int i = 0; i < areaArray.Length; i++)
            {
                if (gameRecord.availableAreas[areaArray[i]])
                {
                    gameRecord.misionsAsigned.Add(misionController.AssignMision("Busqueda", areaArray[i]), areaArray[i].localizations[Random.Range(0,areaArray[i].localizations.Length)].transform);
                }
            }
        }
        else if (!haveMisionsAsigned && gameRecord.searchedArea != null)
        {
            for (int i = 0; i < 3; i++)
            {
                gameRecord.misionsAsigned.Add(misionController.AssignMision(misionTypeArray[Random.Range(0, misionTypeArray.Length)], gameRecord.searchedArea), gameRecord.searchedArea.localizations[Random.Range(0,gameRecord.searchedArea.localizations.Length)].transform);
            }
        }
        if (!gameRecord.estaEnMarxaUnaMisio)
        {
           //Get the mision info from dictionary (like mision.misiondescription) to add it in a funcionality of a button
        }