❔ Using lists interchangeably

Hello, I have a situation where all of my code is the same aside from which lists are used in a for statement. How can I determine which list to use and swap it with a single variable? Example: (Before) switch (ListType) { case 0: for (int x = 0; x < ListA.Count; x++) { } case 1: for (int x = 0; x < ListB.Count; x++) { } case 2: for (int x = 0; x < ListC.Count; x++) { } } (After) for (int x = 0; x < SelectedList.Count; x++) { } (all lists are the same length)
5 Replies
codesandplays
codesandplays2y ago
Need more details are all the lists the same type what is the logic for picking a list
furyion.exe
furyion.exeOP2y ago
all of the lists are the same type(string), the logic for picking a list is the selected index of a combobox(so an int) if I make a list of lists out of ListA, ListB, and ListC, will they be references to those lists or copied? if they would be references that solves my problem, i dont want them copied as they are 20000+ items each
hiyosilver
hiyosilver2y ago
@Furyion they won't be copied.
furyion.exe
furyion.exeOP2y ago
ok good, problem solved then, thanks
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server