also a newer feature for adding safe/local extensions to the objects, called Refinements, but it is known to be less used. In Swift, the extension keyword marks a class-like construct that allows the addition of methods, constructors, and fields to an existing class, including the ability to implement a new interface/protocol to the existing class. Extension methods as enabling feature Next to extension methods allowing code written by others to be extended as described below, extension methods enable patterns that are useful in their own right as well. The predominant reason why extension methods were introduced was Language Integrated Query (LINQ). Compiler support for extension methods allows deep integration of LINQ with old code just the same as with new code, as well as support for query syntax which for the moment is unique to the primary Microsoft .NET languages. Console.WriteLine(new[] { Math.PI, Math.E }.Where(d => d > 3).Select(d => Math.Sin(d / 2)).Sum()); // Output: // 1 Centralize common behavior However, extension methods allow features to be implemented once in ways that enable reuse without the need for inheritance or the overhead of virtual method invocations, or to require implementors of an interface to implement either trivial or woefully complex functionality. A particularly useful scenario is if the feature operates on an interface for which there is no concrete implementation or a useful implementation is not provided by the class library author, e.g. such as is often the case in libraries that provide developers a plugin architecture or similar functionality. Consider the following code and suppose it is the only code contained in a class library. Nevertheless, every implementor of the ILogger interface will gain the ability to write a formatted string, just by including a using MyCoolLogger statement, without having to implement it once and without being required to subclass a class library provided implementation of ILogger. namespace MyCoolLogger; public interface ILogger { void Write(string text); } public static class LoggerExtensions { public static void Write(this ILogger logger, string format, params object[] args) { if (logger != null) logger.Write(string.Format(format, args)); } } use as :var logger = new MyLoggerImplementation(); logger.Write("{0}: {1}", "kiddo sais", "Mam mam mam mam ..."); logger.Write("{0}: {1}", "kiddo sais", "Ma ma ma ma... "); logger.Write("{0}: {1}", "kiddo sais", "Mama mama mama mama "); logger.Write("{0}: {1}", "kiddo sais", "Mamma mamma mamma ... "); logger.Write("{0}: {1}", "kiddo sais", "Elisabeth Lizzy Liz..."); logger.Write("{0}: {1}", "mamma sais", "WHAT?!?!!!"); logger.Write("{0}: {1}",