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.
1 Réponse
+ 1
Use function polymorphism...C++/C#