C# Is there a way to create functions that accept anonymous function code as argument?
<p>I would like to do something like</p>

<pre><code>NameOfTheMethod(parameters){
  // Code...
}
</code></pre>

<p>There's using, foreach, for, etc. that are already built-in, but I don't know if creating something similar is even possible. Is it?</p>

<p>The reason why I ask this is because sometimes that there are many different pieces of code that are wrapped by basically the same code (examples are opening a connection to the database, creating the command, settings the datareader, testing if an element exists in cache and, if not, go get it, otherwise get it from cache, etc.)</p>
