Use: Typically used for auto gereration of code which will be included at runtime using System.Reflection.Emit namespace classes.
Rules : 1. Partial methods should be private,
2. Partial methods should be always void.
3. NO parameters are expected in partial methods.
Example: partial class Model
{
partial void InitializeComponent(); // partial methods should always be private
public void createView()
{
Console.WriteLine("view is created successfully");
InitializeComponent();
}
}
// this section of the code is written in other class
partial class Model
{
partial void InitializeComponent()
{
Console.WriteLine("Implemented by other part of the class implemented in other class");
}
}
class MainClient
{
static void Main()
{
Model model = new Model();
model.createView();
}
}