I am writing a parser which calls some functions dependent on some value.
I can implement this logic with simple switch like this:
switch(some_val)
I strongly prefer the dictionary choice, because with an initializer, it can be a lot more compact and readable:
var actions = new Dictionary
{
{1, () => Console.WriteLine("One!")},
{2, () => Console.WriteLine("Two!")}
}
Also, you have some more flexibility; you can add conditions and actions programatically, which is often handy, depending on what you're doing.