Two dimensional HashSet/List

I need to have 20 groups in my game. Let’s say each group can contain up to 10 gameObjets.
But ofc I don’t want to do:

HashSet<GameObject> group01 = new HashSet<GameObject>(); (HashSet is the same as List)
HashSet<GameObject> group02 = new HashSet<GameObject>();
HashSet<GameObject> group03 = new HashSet<GameObject>();

etc. Up to 20 let’s say. Is there a way to make it something like two dimensional so group[1,GameObject]. I know there are KeyValuePairs but how would I iterate over them? To let’s say find that group ID 3 let’s say and then iterate over those GameObject that are stored in that 3rd position

You can just put the Hashsets inside another hashset or a list:

//Initializing
List<HashSet<GameObject>> groups = new List<HashSet<GameObject>();

for(int i = 0; i < 20; i++)
{
    groups.Add(new HashSet<GameObject>());
}


//Iterating the groups
for(int i = 0; i < groups.Count; i++)
{
    for(int j = 0; j < groups*.Count; j++)*

{
Debug.Log(string.Format(“GameObject {0} number {1} in Group {2}”, groups*[j].Name, j, i));*
}
}