I would like to somehow mark the function (attributes?), So when it is called from anywhere, some other code receives the processing of the parameters and returns a value instead of the called function or it can let the functions execute normally.
I would use it for easy caching.
For example, if I had a function called Add10, it would look like this:
int Add10 (int n)
{
return n + 10;
}
If the go function is called repeatedly with the same value (Add10 (7)), it will always give the same result (17), so it makes no sense to recount every time. Naturally, I would not do this with such simple functions, but I am sure you can understand what I mean.
Does C # provide any way to do what I want? I need a way to mark the function as cached, so when someone does Add10 (16), some code is run somewhere first to check the dictionary, we already know the value Add10 16 and return it, if we do, we calculate keep and if we do not.
source
share