Skip to content

Instantly share code, notes, and snippets.

@GigaOrts
Last active February 28, 2024 18:48
Show Gist options
  • Save GigaOrts/e20f873fb23fbea4c43f02864ba517d9 to your computer and use it in GitHub Desktop.
Save GigaOrts/e20f873fb23fbea4c43f02864ba517d9 to your computer and use it in GitHub Desktop.
class Program
{
enum Command
{
Invalid,
Add,
Remove,
Exit
}
static void Main(string[] args)
{
bool isRunning = true;
while (isRunning)
{
Console.WriteLine($"{(int)Command.Add} - Add to storage");
Console.WriteLine($"{(int)Command.Remove} - Remove from storage");
Console.WriteLine($"{(int)Command.Exit} - Exit the program");
if (Enum.TryParse(Console.ReadLine(), out Command command) == false)
{
Console.WriteLine("Invalid operation");
continue;
}
switch (command)
{
case Command.Add:
Console.WriteLine("Add command complete!");
break;
case Command.Remove:
Console.WriteLine("Remove command complete!");
break;
case Command.Exit:
Console.WriteLine("Exit command complete!");
isRunning = false;
break;
}
}
Console.WriteLine("Bye!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment