0

Method that calls other method based on input

Is there a way to create a method that takes input and calls other methods depending on the input, other than static void Test(string A) { if (A==“Attack”) { Attack(); } ........ } And static void Test(string A) { switch(A) { case “Attack”: Attack(); break; } ........ } I’m trying to make an OOP game for practice and I’ve seen a guy make it using a pretty interesting way using Python so wondering if there’s a C# version of the method. https://code.sololearn.com/c2Mbsk99oqsM/?ref=app Line 96 is where the guy creates the method that takes input.

27th Aug 2020, 4:24 AM
•—• • •-• ••• —- -•
•—• • •-• ••• —- -• - avatar
1 Resposta
+ 1
Use function polymorphism...C++/C#
27th Aug 2020, 10:18 AM
Sanjay Kamath
Sanjay Kamath - avatar