We look at some special cases, through the analysis of these special circumstances, we can better understand extension methods like extended class way as the original method when the processing logic. We are not a third-party open source components of a class extends a method, such as method: Print. After a period of time, this third party has released a new version of the component, such an increase in the Print method.
Code:
namespace name.book
{
public class MyClass123
{
public void Print ()
{
Console.WriteLine ("****");
}
}
static class MyExtensionMethods123
{
internal static void Print (this MyClass123 s)
{
Console.WriteLine123 ( "hi" + s.ToString ());
}
}
Bookmarks