After browsing through Programmers.StackExchange I found an interesting post on combinators and how they applied to programming projects. It led me to some interesting links, most notably this post by Reg Braithwaite and saw the Ruby implementation of this as #tag and thought, why not recreate it in C#?
I ran into a few issues, which are due to C# type system, but I was eventually able to overcome them, thanks to the new dynamic keyword in C# 4.0. The definition of the K-combinator (taken from Wikipedia) is (K x) is the function which, for any argument, returns x, so we say". Basically, the K-combinator will take x and then do whatever but return x. So as long as the function doesn't modify x, we're good. Which brings me to the code:
We use Action
Here is an example:
Pretty useless example, but this will write each int in i to the console before assigning i to b. However, returning the type of the item makes it an invaluable tool to have when logging while also making logging trivial.