using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class example : MonoBehaviour
{
    public TheClass theClassObj;
    public static Dictionary<string, TheClass> dictionary = new Dictionary<string, TheClass>();
    public class TheClass
    {
        public string valueToDetect;
        public TheClass(string _value)
        {
            valueToDetect = _value;
            dictionary.Add(valueToDetect, this);
        }
    }
    
    public static TheClass TheObject1 = new TheClass("123");
    public static TheClass TheObject2 = new TheClass("321");
    void Start()
    {
        if(dictionary.ContainsKey("123"))
        {
            theClassObj = dictionary["123"];
        }
        else
        {
            Debug.LogError("you didn't do anything to ensure whatever value you are actually checking is included in the dictionary");
        }
    }
}