C# language feature:

  • Partial methods

applies to

  • class methods

benefit

  • Allows place holders for method code (definition and implementation) and facilitates hand coding (developers) and auto generated working together without run-time costs.

how to use

  • A partial method declaration consists of two parts: the definition, and the implementation. Use partial keyword preceding the class definition and method definition and implementation.

note

  • Compiler optimizes away both the defining declaration and all calls to the method if there is no implementation of method. Also, like Partials definition and implementation can be within the same or multiple files

see also

  • Partials

example:

    partial class Partial_Method_Example{
            // Definition in file1.cs  
            partial void onNameChanged();

            // Implementation in file2.cs  
            partial void onNameChanged()
            {
                // method body  
            }  
       }