C#: Virtual Function invocation is even faster than a delegate invocation?
It just happens to me about one code design question. Say, I have one "template" method that invokes some functions that may "alter". A intuitive design is to follow "Template Design Pattern". Define the altering functions to be "virtual" functions to be overridden in subclasses. Or, I can just use delegate functions without "virtual". The delegate functions is injected so that they can be customized too. Originally, I thought the second "delegate" way would be faster than "virtual" way, but some coding snippet proves it is not correct. In below code, the first DoSomething method follows