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 Answer
+ 1
Use function polymorphism...C++/C#
27th Aug 2020, 10:18 AM
Sanjay Kamath
Sanjay Kamath - avatar