Hi, guys!
I have a number of Lists, each storing some data.
I would like to extract some of it from each List.
I decided to put every list in a List and loop through it.
I am not sure it is possible and whether it is the correct way to solve the problem.
Could you please help me? Thanks!
Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
public List<int> test_container_list_1 = new List<int>();
public List<int> test_container_list_2 = new List<int>();
public List<int> test_container_list_3 = new List<int>();
void Start()
{
test_container_list_1.Add(1);
test_container_list_1.Add(11);
test_container_list_1.Add(111);
test_container_list_2.Add(2);
test_container_list_2.Add(22);
test_container_list_2.Add(222);
test_container_list_3.Add(3);
test_container_list_3.Add(33);
test_container_list_3.Add(333);
//create the List to put other lists in it.
//Maybe use iList instead of List?
the_ultimate_list = new List<IList>();
the_ultimate_list.Add(test_container_list_1);
the_ultimate_list.Add(test_container_list_2);
the_ultimate_list.Add(test_container_list_3);
//is it possible?
//and then loop through it to fetch some data?
to_remember = new GameObject;
foreach (List looking_list in the_ultimate_list){
if (looking_list[2] == "222")
Debug.Log("it is");
to_remember = looking_list[2];
}
}
}