title: Function pointers with differing return types in C#
body: <p>I'm going through the fun process of porting an ActionScript project over to C#.  One of the interesting features I've found is the very relaxed type checking in ActionScript.</p>
  
  <p>As an example -</p>
  
  <pre><code>table = new Dictionary();
  table["id1"]    = func1;
  table["id2"]    = func2;
  table["id3"]    = func3;
  table["id4"]    = func4;
  </code></pre>
  
  <p>Where func1, func2, func3 and func4 all have the same parameter types but some of them return void and some return object types is totally acceptable in ActionScript.</p>
  
  <p>I was going to tackle this using delegates until I realised they had differing return types.</p>
  
  <p>Is there a clean way to handle this in C# without refactoring and, if so, what is it?</p>
  
  <p>[EDIT] I'm not condoning the way the original code was written.  It checks the id of the function and processes differently depending on what it expects to be returned (or to not be returned).  I could refactor this but would rather port the project across as a whole and then work on structure improvements.</p>
  
  <p>[EDIT] The code I'm porting is a computer language parser (interpreter not compiler). It uses the computer keywords as the keys into the table's dictionary, calling the appropriate functions to carry out those commands. Some commands return void because they just perform processing. Some return values (such as GetVar functions).</p>