Execute code before the called function is executed
<p>I would like to be able to mark a function somehow (attributes maybe?) so that when it's called from anywhere, some other code gets to process the parameters and return a value instead of the called function, or can let the function execute normally.</p>

<p>I would use it for easy caching.</p>

<p>For example, if I had a function called Add10 and it would look like this:</p>

<pre><code>int Add10 (int n)
{
    return n + 10;
}
</code></pre>

<p>If the function go called repeatedly with the same value (Add10(7)) it would always give the same result (17) so it makes no sense to recalculate every time. Naturally, I wouldn't do it with functions as simple as this but I'm sure you can understand what I mean.</p>

<p>Does C# provide any way of doing what I want?
I need a way to mark a function as cached so that when someone does Add10(16) some code somewhere is ran first to check in a dictionary is we already know the Add10 value of 16 and return it if we do, calculate, store and return if we don't.</p>
