I'm building an app to test some equipment and the app will have 43 test steps (Step01.cs
to Step43.cs
). (tests are massive and need to be split in separate files)
In each .cs file there is a public static void Test(){}
function.
At any given point the user can go back and redo a test and at the end of each test the user is asked if he wants to redo the next step(only if it has been previously done). If next step has never been done, it continues with the test as usual.
if (currentStep < maxStep )
{
for(int i = currentStep; i < maxStep; i++)
{
_form1.testNumberComboBox.SelectedIndex = i - 1;
if (MessageBox.Show($"{_form1.testNameComboBox.SelectedItem.ToString()} has already been tested.\nWould you like to retest?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Step02.Test(_form1, sensor);
return;
}
}
_form1.testNumberComboBox.SelectedIndex = maxStep - 1;
}
My question is if it possible to do something like this Step{i}.Test(_form1, sensor);
to call what test I need, as I don't really want to do if(i == 2){Step02.Test(_form1, sensor);}...if(i == 40){Step40.Test(_form1, sensor);}
if the answer from the user is Yes.
I've done something like this in PHP a while back. Had variables $acc1, $acc2 ... $accX
and was able to call them in a for(i) loop with ${"acc$i"}
.
I'm not sure if it is possible in C# and that is why I'm asking. (I'm new to C#)