I am trying to implement the trapezodial rule in c# as a function:

```
Int_a^b f(x) = (b-a) * [f(a) + f(b)] / 2 

```

Is there a feature in c# which allows me to write the function as such?

```
double integrate(double b, double a, function f)
{
    return (b-a) * (f(a) + f(b)) / 2;
}

```

Where `f` can be any polynomial expression defined inside another function, for example:

```
double f (double x)
{
    return x*x + 2*x;
}

```