DQbB?JgB?PPh{fpPmh^UyhSUyUKqPUKhJA%{PghPhyhyh'hDQb?JB?iihi{KhJA%{{iMy'MaAabAeEBCfBeXWBC| 576645}4WCWZ 56655VCBZC-

Extension.` An extension method has simplified calling syntax. It represents a static method as an instance method. Extension methods can lead to simpler syntax.`This keyword.` An extension method uses the this-keyword in its parameter list. It must be located in a static class. We often use special "Extensions" classes.`An example.` Here is a custom extension method. Usually you will want to store your extension method class in a separate source file (like ExtensionMethods.cs) in the project. `This file should store a static class with public static extension methods.`Public `public`Then: `In the rest of your source code, you can invoke these extension methods in the same way as instance methods.`Notes, above program.` You can see an extension method declaration. An extension method must be static and can be public so you can use it anywhere in your source code. `The extension method is called like an instance method, but is actually a static method. The instance pointer "this" is a parameter.`You must specify the this-keyword before the appropriate parameter you want the method to be called upon.`Notes, continued.` The only difference in the declaration between a regular static method and an extension method is the "this" keyword in the parameter list. `Important: `If you want the method to receive other parameters, you can include those at the end.`Second parameter.` Here is an extension method that acts on ints. It receives a parameter—the multiplier for the operand. It returns another int so can be used in function call chains. `Return `return`LINQ.` There are many extension methods available. These extension methods were written by Microsoft developers and are available in all C# programs targeting recent .NET Framework versions. `On most of the extension methods, you need to add the "using System.Linq" directive to the top of the code.`LINQ `linq`A discussion.` Extension methods can have many arguments. We can use variable "params" arguments with extension methods. Extension methods are static methods—so there is no performance loss. `Params `params`So: `Extension methods affect the high-level representation of the code, not the low-level implementation.`A summary.` You can add extension methods to any type, even a value type. The original representation of the type does not change. Extension methods affect syntax, not execution.

567 666666ExtensionM6s { 5666 7UppercaseFirstLetter7(7this7 6 6) 5{7 556Upper6the first letter6the 6. 55766.L6 > 0) 55{ 555char[] 666.ToChar6(); 5556[0]6char.ToUpper(6[0]); 5556 66(6); 55} 556 6; 5} } 66 { 565{7 556Use the 6 extension m6 on this 6. 5576 667"dot net perls"7; 55666.7UppercaseFirstLetter7(); 5566); 5} } 7 7D7ot net perls7 66666Extensions { 56667MultiplyBy7(this 66, 6mulitiplier) 5{7 556Uses a second parameter after the instance parameter. 5576 6 * mulitiplier; 5} } 66 { 565{7 556Ten times 2 is 20. 556Twenty times 2 is 40. 55766610.7MultiplyBy7(2).7MultiplyBy7(2); 5566); 5} } 7 407

"jnextension method on stringextension method, 2 parameters