An extension method is a static method, which is part of a class, but is not actually placed in the source code of the class. For some reason, the original source code of the assembly cannot be modified directly. All the work you have to do at this point is to create a static class
1 namespaceWrox2 {3 Public Static classmoneyextension4 {5 Public Static voidAddtoamount ( ThisMoney Money,decimalAmounttoadd)6 {7Money. Amount + =Amounttoadd;8 }9 }Ten}
Note the parameters of the Addtoamount () method. For an extension method, the first parameter is the type to be extended, which is placed after the This keyword. This tells the compiler that this method is part of the money type. In this example, money is the type to be extended. In an extension method, you can access all public methods and properties of the extended type.
"C # Advanced Programming" Learning notes