How to refactor a large switch case statement that changes via a Console.Readline string?
I have read up multiple websites and Stack Overflow posts regarding this but still do not seem to understand nor know if this is the correct way. Still fairly new to c#.
I have a Console.ReadLine which accepts user Input, I also have a switch case which switches based on the User input
string cmd = Console.ReadLine();
switch(cmd) {
case "login":
//Execute Login Logic here
break;
case "logout":
//Execute Logout logic here
break;
//etc.etc.
}
I'm expecting there is some better way to refactor this to stop me needing a larger and larger switch case statement, I have been reading about conditional polymorphism although I am unsure if this is correct, Could someone help me to better understand how i would accomplish this?