title: Is there a way to save a method in a variable then call it later? What if my methods return different types?
body: <p>Edit: Thank you for the answers. I am currently working on it!!\</p>
  
  <p>I have 3 methods, S() returns string, D() returns double and B() returns bool.</p>
  
  <p>I also have a variable that decides which method I use.
  I want do this:</p>
  
  <pre><code>    // I tried Func&lt;object&gt; method; but it says D() and B() don't return object.
      // Is there a way to use Delegate method; ? That gives me an eror saying method group is not type System.Delegate
      var method;
  
      var choice = "D";
  
      if(choice=="D")
      {
          method = D;
      }
      else if(choice=="B")
      {
          method = B;
      }
      else if(choice=="S")
      {
          method = S;
      }
      else return;
  
      DoSomething(method); // call another method using the method as a delegate.
  
      // or instead of calling another method, I want to do:
      for(int i = 0; i &lt; 20; i++){
         SomeArray[i] = method();
      }
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>I read this post:
  <a href="https://stackoverflow.com/questions/2008392/storing-a-method-as-a-member-variable-of-a-class-in-c">Storing a Method as a Member Variable of a Class in C#</a>
  But I need to store methods with different return types...</p>