1. Extension Method
Requirements for extension methods:
1. The first parameter is the type to be extended or to be operated, which becomes the "extended type ".
2. to specify the extension method, add the this modifier before the extended type name.
3. Use the method as an extension method. Use Using to specify the namespace to import the extension type, or specify the extension type and call.CodeIn the same namespace.
Public static class directoryextension <br/>{< br/> Public static void copyto (this directoryinfo sourcedir, <br/> string target) {}< br/>}</P> <p> class Program <br/>{< br/> static void main (string [] ARGs) <br/>{< br/> string STR = "testpath"; <br/> directoryinfo dir = new directoryinfo (STR); <br/> dir. copyto (STR); <br/>}< br/>}
2 base class Rewriting
1 virtual Modifier
C # supports rewriting of instance methods and attributes, but does not support rewriting of fields or any static members .. If a public or protected member does not contain a virtual modifier, the member cannot be overwritten by a subclass. The override method explicitly uses the override keyword.
2 new Modifier
It hides the re-declared member of the derived class in the face of accumulation. In this case, it is not a member that calls the derived element. On the contrary, the members of the base class search for the inheritance chain, find the member before the new modifier, and then call the member.
3 sealed modifier. In this way, the subclass is prohibited from being declared as a virtual base class member.
4 Base member.
5 abstract class. Abstract members are non-implemented methods or attributes. They force all derived classes to provide implementations. Realize polymorphism, similar to C ++