Friday, February 3, 2017

what is the use of partial class in C#

A partial class splits the definition of a class over two or more source files. You can create a class definition in multiple files but it will be compiled as one class.

More than one developer can simultaneously write the code for the class.
Suppose you have a "Emp" class. That definition is divided into the two source files "Emp1.cs" and "Emp2.cs". Then these two files have a class that is a partial class. You compile the source code, then create a single class.
Or Suppose you have a class that has multiple interfaces so you can create multiple source files depending on interface implements. It is easy to understand and maintain an interface implemented on which the source file has a partial class.