I would like to do something like
NameOfTheMethod(parameters){
// Code...
}
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?
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.)
Yes, you can take a delegate instance as an argument:
You’d call it like: