Use of “this” keyword in formal parameters for static methods in C#

This is an extension method. See here for an explanation.

Extension methods allow developers to add new methods to the public
contract of an existing CLR type, without having to sub-class it or
recompile the original type. Extension Methods help blend the
flexibility of “duck typing” support popular within dynamic languages
today with the performance and compile-time validation of
strongly-typed languages.

Extension Methods enable a variety of useful scenarios, and help make
possible the really powerful LINQ query framework… .

it means that you can call

MyClass myClass = new MyClass();
int i = myClass.Foo();

rather than

MyClass myClass = new MyClass();
int i = Foo(myClass);

This allows the construction of fluent interfaces as stated below.

Leave a Comment