0
Calling a function in a switch statement
Hi guys I just wanted to find out can you call a function in a switch statement and if its possible how do you call it in C#. For e.g Let's say the function name is people And now in the main function. Switch(Console.Readline()){ case "1": "Call the function people here"; Break; } Thank You.
2 Respuestas
+ 2
You can do that in any of the labels defined (the "case" labels) but I'm not sure you can do it outside the labels.
Call the function like you would call other functions.
And don't forget to use `break` on each label for safety 👍
0
Yes, absolutely you can do it
https://code.sololearn.com/cVQmy4YH516S/?ref=app