Search This Blog

Friday, December 14, 2012

Partial Class c#

C# > Class > Partial

Partial split the definition of a class over  more source files.
Each source file contains a section of the class definition, and all parts are combined when the application is compiled.

Use partial class when:
  • working on large projects allows multiple programmers to work on it simultaneously.
  • working with automatically generated source, code can be added to the class without having to recreate the source file.
Example

public partial class Car
{
      public int Year()
     {
      }
}

public partial class Car
{
      public void Go()
     {
      }
}