Dictionary<string, List<Piese>> SetPiese = new Dictionary<string, List<Piese>>();
char[] litere = "ABCDEFGHIJLMNOPRSTUVXZ".ToCharArray();
for (int i = 1; i <= litere.Length; i++) {
SetPiese.Add(litere[i], Set + litere[i]);
}
List<Piese> SetA = GenerareSetLitere("A", 1, 11);
List<Piese> SetB = GenerareSetLitere("B", 9, 2);
List<Piese> SetC = GenerareSetLitere("C", 1, 5);
................................................
So I have many lists and I want to add them to a dictionary. How can I do this right ?
Quite simply, don’t declare them in separate variables to start with. That will always be a pain to work with programmatically. If you’d started with:
then you could use:
Or even better, if
literereis actually a bunch of expressions you can specify inline, you could do the whole thing in a collection initializer:etc.