0

Possible Duplicate:
What is the use of a partial class?

In my code ,there is one partial class for creating new company. I can not understand in which condition partial to be implemented.

public partial class NewCompanyWindow : Window
{
    List<Company> _companies;
    public event EventHandler<CompanyAddedEventArgs> CompanyAdded;

    public NewCompanyWindow()
    {
        InitializeComponent();

        Closing += new
          System.ComponentModel.CancelEventHandler(NewCompanyWindow_Closing);
    }

    void NewCompanyWindow_Closing(object sender,
         System.ComponentModel.CancelEventArgs e)
    {
        StartupWindow w = new StartupWindow();
        w.Show();
    }

    public NewCompanyWindow(List<Company> companies)
        : this()
    {
        _companies = companies;
    }

    private void CreateButton_Click(object sender, RoutedEventArgs e)
    {..

can any one say in which condition partial class is used?

Community
  • 1
  • 1
prjndhi
  • 1,915
  • 4
  • 17
  • 26

2 Answers2

2

Partial classes should be used when you want to split the implementation of a class across multiple code files. Typically, this approach is warranted when you have a class that is partially user-defined and partially generated, such as a Windows Form.

Part of the class is defined in Form1.cs and the designer-generated code is in Form1.designer.cs. Both class contain implementations of the class Form1, but typically the developer doesn't edit the code in the 'designer' file, but can still customize the Form1 class by editing the Form1.cs file

Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73
0

Partial class can be extended. It is used to break up one class into multiple files.

fenix2222
  • 4,602
  • 4
  • 33
  • 56