Mercy G
New member
- Joined
- Mar 10, 2021
- Messages
- 2
- Programming Experience
- 1-3
Hello everyone,
I have a Visual Studio project that has multiple void methods named Ex1(), Ex2(), Ex3(), ..., Ex8().
I would like to call them all in the Main function, one after the other, so that on the console I have the display of all the exercices successively.
Is it possible to create a loop (from 1 to 8) that changes the name of the method to "Ex"+the number, and calls that method ?
I tried this but it doesn't work :
Thank you for your help,
Martin
I have a Visual Studio project that has multiple void methods named Ex1(), Ex2(), Ex3(), ..., Ex8().
I would like to call them all in the Main function, one after the other, so that on the console I have the display of all the exercices successively.
Is it possible to create a loop (from 1 to 8) that changes the name of the method to "Ex"+the number, and calls that method ?
I tried this but it doesn't work :
C#:
string Exo;
for (int z = 1; z <= 8; z++)
{
Exo = "Ex"+z;
Exo();
}
Thank you for your help,
Martin