public class FluentClass { private int value; public FluentClass WithValue(int value) { this.value = value; return this; } public FluentClass AddOne() { this.value += 1; return this; } public FluentClass SubstractTwo() { this.value -= 2; return this; } public FluentClass MultiplyThree() { this.value *= 3; return this; } public FluentClass DrawValue() { Console.WriteLine(this.value); return this; } } static void Main(string[] args) { var fluent = new FluentClass() .WithValue(9) .DrawValue() .AddOne() .DrawValue() .SubstractTwo() .DrawValue() .MultiplyThree() .DrawValue(); Console.ReadLine(); }
En la wikipedia existen ejemplos en Ruby, java, scala y c++.
Dejo link:
http://en.wikipedia.org/wiki/Fluent_interface