title: C# Passing Function as Argument
body: <p>I've written a function in C# that does a numerical differentiation. It looks like this:</p>
  <pre><code>public double Diff(double x)
  {
      double h = 0.0000001;
  
      return (Function(x + h) - Function(x)) / h;
  }
  </code></pre>
  <p>I would like to be able to pass in any function, as in:</p>
  <pre><code>public double Diff(double x, function f)
  {
      double h = 0.0000001;
  
      return (f(x + h) - f(x)) / h;
  }
  </code></pre>
  <p>I think this is possible with delegates (maybe?) but I'm not sure how to use them.</p>