Hello, guys! Could you please help me with retrieving the value of a key, contained in a list?
Here is the script:
public Hashtable all_containers_hashtable = new Hashtable();
public List<string> container_list_1 = new List<string>();
public List<string> container_list_2 = new List<string>();
// Start is called before the first frame update
void Start()
{
container_list_1.Add("name_1");
container_list_1.Add("description_1");
container_list_1.Add("param_1_1");
container_list_1.Add("param_1_2");
container_list_1.Add("param_1_3");
all_containers_hashtable.Add("card_1", container_list_1);
container_list_2.Add("name_2");
container_list_2.Add("description_2");
container_list_2.Add("param_2_1");
container_list_2.Add("param_2_2");
container_list_2.Add("param_2_3");
all_containers_hashtable.Add("card_2", container_list_2);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Q)) {
Debug.Log(all_containers_hashtable["container_list_1"]);
//returns the type: List
Debug.Log(all_containers_hashtable["container_list_1"][1]);
// D o e s n ' t w o r k (intended, it will return "description_1"), instead it gives error
}
}