Hi,
I am writing a parser, which call some functions dependent on some value.
I can implement this logic with simple switch like this
switch(some_val)
{
case 0:
func0();
break;
case 1:
func1();
break;
}
or with delegates and dictionary like this
delegate void some_delegate();
Dictionary<int, some_delegate> some_dictionary = new Dictionary<int, some_delegate>();
some_dictionary[0] = func0;
some_dictionary[1] = func1;
some_dictionary[some_value].Invoke();
Are this two methods equal and which is preferred?
Thanks.