Practice ยท 2 of 4
Operator dispatch table
CHALLENGE
Difficulty: beginner+25 XP
Implement static int Eval(char op, int a, int b) using a dispatch table of Func<int, int, int> (dictionary from char to function): '+' 'โ' '*' '/' (integer division). Unknown operator โ ArgumentException. Division by zero propagates naturally.
Press Submit to check your solution.
Back to lesson: Practice: Delegates workout