furyion.exe
❔ 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)
10 replies
❔ Is it possible to use a variable name in an object call?
Forgive me if I worded it wrong(that is probably part of the problem of why I can't find information on this), but I want to know if this is possible, and if so, how.
Example:
I have 4 textboxes: StrengthTextbox, DexterityTextbox, VitalityTextbox, FocusTextbox
I am making a calculator for skills in a game, and these skills can be based on any of these 4 attributes(using them in their equations)
Is there some kind of way where I can call these textboxes in a way like... attribute + Textbox.Text?
18 replies