accessing multiple lists?

Hello. I have multiple lists which are all of type <string, string>. I also have objects that will be named the same as what the first string holds in the different lists. When i click this object i want to be able to find it in its list and then print the information that the second string hold.

I have this working with 1 list, because i know the list that is being used so i can just access it directly using its name. ie

if ((clickedWord== ListOne[num].secondInList.ToString()))     
                    FirstTextElement.text = ListOne[num].firstInList.ToString();      
                }

However, I am not sure how to integrate multiple lists, does anyone possibly have any ideas at how i could accomplish this. I know i could just test every list to see if the word is in it, but that seems like a terrible idea

Is what you mean this?

List<List<string>> myLists;

you can also do this with things like a Hashset or Queue, it’s not just limited to lists

Hi, Sorry i completely forgot that I made the list out of a class. So the class has two string variables, so the list holds multiple objects of the same class, and i access it using what i showed above.

The objects are going to be different things, so say I have a list for numbers, and a list for letters. Some objects will be named after numbers found in the numbers list and then some objects will be named after the letters in the letters list, so I need to keep these separate, so I would not be able to use one data structure for them all.

sorry, I probably wasn’t the best person to answer this forum, I haven’t really worked with what you’re describing before so I’m not exactly sure how to help, would you be okay showing me a picture of what you’re trying to do? I might be able to help better that way

No problem :). It might help if I try and explain what I am trying to do.

So its a language learning game, and I have a class for food types and a class for greetings (There might be more eventually). These classes I am using to insert into lists, since I need the second language words with the english words. This is the code for one of the class/lists

public class greetingConversion          
{
    public string FWord;
    public string englishWord;

    public greetingConversion(string F, string english)
    {
        FWord= F;
        englishWord = english;
    }
}
List<greetingConversion> greetingConvert = new List<greetingConversion>();
        greetingConvert.Add(new greetingConversion("F-Hi", "Hi"));
        greetingConvert.Add(new greetingConversion("F-Goodday", "Goodday"));

Then I a text mesh pro object that will chose randomly from the greeting list and from the food list. When I click the word on the text mesh pro I want to be able to find what list that word is in, and then display the english. The clicking and displaying part is all working with the one list, but its when im trying to use it with multiple lists its not working.

EDIT : I am going to try adding in another list, and filling that with each greeting or food that is displayed, and then using that list to display the english. Then clear the list each time a new food/greeting is displayed. I am hoping this will work, but im not sure if its a good way to do it, any opinions welcome :slight_smile:

That seems like an okay way to do it, as long as the list is that long it shouldn’t really effect performence