نمونه در C#:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace fluent { class Person { public String Name { get; private set; } public int Age { get; private set; } public Person WithName(String name) { Name = name; return this; } public Person WithAge(int age) { Age = age; return this; } } class Program { static void Main(string[] args) { Person Ali = new Person().WithName("Ali").WithAge(16); Console.WriteLine("Name:{0}",Ali.Name); Console.WriteLine("Age:{0}", Ali.Age); Console.ReadKey(); } } }
#include <iostream> #include <stdio.h> #include <string> using namespace std; class Person { public: const char* Name; int Age; Person WithName(const char* name) { Name = name; return *this; } Person WithAge(int age) { Age = age; return *this; } }; int main() { Person Ali = Person().WithName("Ali").WithAge(16); cout << "Name:" << Ali.Name << "\nAge:" << Ali.Age; getchar(); return 0; }
http://en.wikipedia.org/wiki/Fluent_interface
http://www.doolwind.com/blog/fluent-game-design-with-fluent-interfaces/