Can you please tell me what kind of construct in C# is this.
Code Golf: Numeric equivalent of an Excel column name
C.WriteLine(C.ReadLine()
.Reverse()
.Select((c, i) => (c - 64) * System.Math.Pow(26, i))
.Sum());
Though I am new to C# (only two months exp so far), but since the time I have joined a C# team, I have never seen this kind of chaining. It really attracted me and I want to learn more about it.
Please give some insight about this.
Method chaining like this is often called a fluent interface.
You can make your own fluent interface by implementing functions that return the object they were called on.
For a trivial example:
Which can be used like:
You could also implement a fluent interface using extension methods.
For example:
etc.
Here is a more complex example. Finally, Autofac and CuttingEdge.Conditons are two examples of open-source libraries that have very nice fluent interfaces.