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.

1st May 2021, 12:09 PM
Obakeng T Aphane
Obakeng T Aphane - avatar
2 Antworten
+ 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 👍
1st May 2021, 12:18 PM
Ipang
1st May 2021, 10:13 PM
hossein B
hossein B - avatar